﻿function checkFormRule(frm) {
    try {
        var oAll = frm.all;
        var oItem, s, r;
        for (i = 0; i < oAll.length; i++) {
            oItem = oAll[i];
            s = oItem.tagName.toLowerCase();
            if (s == "input" || s == "select") {
                if ("rule" in oItem) {
                    r = new RegExp(oItem.rule);
                    if (!r.test(oItem.value)) {
                        alert(oItem.msg);
                        oItem.focus();
                        if (s == "input") oItem.select();
                        return false;
                    }
                }
            }
        }
        return true;
    }
    catch (e) {
        alert(e);
        return false;
    }
}

function openWin(url, arg, w, h) {
    return showModalDialog(url, arg, "dialogWidth:" + w + "px; dialogHeight:" + h + "px; status:0;help:no")
}
String.prototype.trim = function () {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}
function mergecell(tb) {
    var iRowCnt = tb.rows.length;
    if (iRowCnt <= 1) return;
    var iPreIndex = 1;
    var sPreText = tb.rows(iPreIndex).cells(0).innerText;
    var sCurText = "";
    for (var i = 2; i < iRowCnt; i++) {
        sCurText = tb.rows(i).cells(0).innerText;
        if (sCurText == sPreText) {
            tb.rows(iPreIndex).cells(0).rowSpan++;
            tb.rows(i).deleteCell(0);
        }
        else {
            iPreIndex = i;
            sPreText = sCurText;
        }
    }
}
function Node(id, pid, name, url, menu, title, target, icon, iconOpen, open) {
    this.id = id;
    this.pid = pid;
    this.name = name;
    this.url = url;
    this.menu = menu;
    this.title = title;
    this.target = target;
    this.icon = icon;
    this.iconOpen = iconOpen;
    this._io = open || false;
    this._is = false;
    this._ls = false;
    this._hc = false;
    this._ai = 0;
    this._p;
};
function dTree(objName, iconPath) {
    this.config =
    {
        target: null, folderLinks: true, useSelection: true, useCookies: true, useLines: true, useIcons: true, useStatusText: false, closeSameLevel: false, inOrder: false, iconPath: iconPath
    }
    this.icon =
    {
        root: this.config.iconPath + 'flow.gif', folder: this.config.iconPath + 'folder.gif', folderOpen: this.config.iconPath + 'folderopen.gif', node: this.config.iconPath + 'page.gif', empty: this.config.iconPath + 'empty.gif', line: this.config.iconPath + 'line.gif', join: this.config.iconPath + 'join.gif', joinBottom: this.config.iconPath + 'joinbottom.gif', plus: this.config.iconPath + 'plus.gif', plusBottom: this.config.iconPath + 'plusbottom.gif', minus: this.config.iconPath + 'minus.gif', minusBottom: this.config.iconPath + 'minusbottom.gif', nlPlus: this.config.iconPath + 'nolines_plus.gif', nlMinus: this.config.iconPath + 'nolines_minus.gif'
    };
    this.obj = objName;
    this.aNodes = [];
    this.aIndent = [];
    this.root = new Node(-1);
    this.selectedNode = null;
    this.selectedFound = false;
    this.completed = false;
};
dTree.prototype.add = function (id, pid, name, url, menu, title, target, icon, iconOpen, open) {
    this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, menu, title, target, icon, iconOpen, open);
};
dTree.prototype.openAll = function () {
    this.oAll(true);
};
dTree.prototype.closeAll = function () {
    this.oAll(false);
};
dTree.prototype.toString = function () {
    var str = '<div class="dtree">\n';
    if (document.getElementById) {
        if (this.config.useCookies) this.selectedNode = this.getSelected();
        str += this.addNode(this.root);
    }
    else str += 'Browser not supported.';
    str += '</div>';
    if (!this.selectedFound) this.selectedNode = null;
    this.completed = true;
    return str;
};
dTree.prototype.addNode = function (pNode) {
    var str = '';
    var n = 0;
    if (this.config.inOrder) n = pNode._ai;
    for (n; n < this.aNodes.length; n++) {
        if (this.aNodes[n].pid == pNode.id) {
            var cn = this.aNodes[n];
            cn._p = pNode;
            cn._ai = n;
            this.setCS(cn);
            if (!cn.target && this.config.target) cn.target = this.config.target;
            if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
            if (!this.config.folderLinks && cn._hc) cn.url = null;
            if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
                cn._is = true;
                this.selectedNode = n;
                this.selectedFound = true;
            }
            str += this.node(cn, n);
            if (cn._ls) break;
        }
    }
    return str;
};
dTree.prototype.node = function (node, nodeId) {
    var str = '<div class="dTreeNode">' + this.indent(node, nodeId);
    if (this.config.useIcons) {
        if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
        if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
        if (this.root.id == node.pid) {
            node.icon = this.icon.root;
            node.iconOpen = this.icon.root;
        }
        str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" border="0" alt="" align="absmiddle"/>';
    }
    if (node.url) {
        str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href=\'' + node.url + '\' onfocus="blur()" oncontextmenu=\'this.click();' + node.menu + '\'';
        if (node.title) str += ' title="' + node.title + '"';
        if (node.target) str += ' target="' + node.target + '"';
        if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
        if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
            str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
        str += '>';
    }
    else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
        str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
    str += node.name;
    if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
    str += '</div>';
    if (node._hc) {
        str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
        str += this.addNode(node);
        str += '</div>';
    }
    this.aIndent.pop();
    return str;
};
dTree.prototype.indent = function (node, nodeId) {
    var str = '';
    if (this.root.id != node.pid) {
        for (var n = 0; n < this.aIndent.length; n++)
            str += '<img src="' + ((this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty) + '" border="0" align="absmiddle" alt="" />';
        (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
        if (node._hc) {
            str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" onfocus="blur()"><img id="j' + this.obj + nodeId + '" src="';
            if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
            else str += ((node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus));
            str += '" border="0" alt="" align="absmiddle" /></a>';
        }
        else str += '<img src="' + ((this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join) : this.icon.empty) + '" border="0" align="absmiddle" alt="" />';
    }
    return str;
};
dTree.prototype.setCS = function (node) {
    var lastId;
    for (var n = 0; n < this.aNodes.length; n++) {
        if (this.aNodes[n].pid == node.id) node._hc = true;
        if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
    }
    if (lastId == node.id) node._ls = true;
};
dTree.prototype.getSelected = function () {
    var sn = this.getCookie('cs' + this.obj);
    return (sn) ? sn : null;
};
dTree.prototype.s = function (id) {
    if (!this.config.useSelection) return;
    var cn = this.aNodes[id];
    if (cn._hc && !this.config.folderLinks) return;
    if (this.selectedNode != id) {
        if (this.selectedNode || this.selectedNode == 0) {
            eOld = document.getElementById("s" + this.obj + this.selectedNode);
            eOld.className = "node";
        }
        eNew = document.getElementById("s" + this.obj + id);
        eNew.className = "nodeSel";
        this.selectedNode = id;
        if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
    }
};
dTree.prototype.o = function (id) {
    var cn = this.aNodes[id];
    this.nodeStatus(!cn._io, id, cn._ls);
    cn._io = !cn._io;
    if (this.config.closeSameLevel) this.closeLevel(cn);
    if (this.config.useCookies) this.updateCookie();
};
dTree.prototype.oAll = function (status) {
    for (var n = 0; n < this.aNodes.length; n++) {
        if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
            this.nodeStatus(status, n, this.aNodes[n]._ls)
            this.aNodes[n]._io = status;
        }
    }
    if (this.config.useCookies) this.updateCookie();
};
dTree.prototype.openTo = function (nId, bSelect, bFirst) {
    if (!bFirst) {
        for (var n = 0; n < this.aNodes.length; n++) {
            if (this.aNodes[n].id == nId) {
                nId = n;
                break;
            }
        }
    }
    var cn = this.aNodes[nId];
    if (cn.pid == this.root.id || !cn._p) return;
    cn._io = true;
    cn._is = bSelect;
    if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
    if (this.completed && bSelect) this.s(cn._ai);
    else if (bSelect) this._sn = cn._ai;
    this.openTo(cn._p._ai, false, true);
};
dTree.prototype.closeLevel = function (node) {
    for (var n = 0; n < this.aNodes.length; n++) {
        if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {
            this.nodeStatus(false, n, this.aNodes[n]._ls);
            this.aNodes[n]._io = false;
            this.closeAllChildren(this.aNodes[n]);
        }
    }
}
dTree.prototype.closeAllChildren = function (node) {
    for (var n = 0; n < this.aNodes.length; n++) {
        if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {
            if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
            this.aNodes[n]._io = false;
            this.closeAllChildren(this.aNodes[n]);
        }
    }
}
dTree.prototype.nodeStatus = function (status, id, bottom) {
    eDiv = document.getElementById('d' + this.obj + id);
    eJoin = document.getElementById('j' + this.obj + id);
    if (this.config.useIcons) {
        eIcon = document.getElementById('i' + this.obj + id);
        eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
    }
    eJoin.src = (this.config.useLines) ? ((status) ? ((bottom) ? this.icon.minusBottom : this.icon.minus) : ((bottom) ? this.icon.plusBottom : this.icon.plus)) : ((status) ? this.icon.nlMinus : this.icon.nlPlus);
    eDiv.style.display = (status) ? 'block' : 'none';
};
dTree.prototype.clearCookie = function () {
    var now = new Date();
    var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
    this.setCookie('co' + this.obj, 'cookieValue', yesterday);
    this.setCookie('cs' + this.obj, 'cookieValue', yesterday);
};
dTree.prototype.setCookie = function (cookieName, cookieValue, expires, path, domain, secure) {
    document.cookie = escape(cookieName) + '=' + escape(cookieValue)
    + (expires ? '; expires=' + expires.toGMTString() : '')
    + (path ? '; path=' + path : '')
    + (domain ? '; domain=' + domain : '')
    + (secure ? '; secure' : '');
};
dTree.prototype.getCookie = function (cookieName) {
    var cookieValue = '';
    var posName = document.cookie.indexOf(escape(cookieName) + '=');
    if (posName != -1) {
        var posValue = posName + (escape(cookieName) + '=').length;
        var endPos = document.cookie.indexOf(';', posValue);
        if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
        else cookieValue = unescape(document.cookie.substring(posValue));
    }
    return (cookieValue);
};
dTree.prototype.updateCookie = function () {
    var str = '';
    for (var n = 0; n < this.aNodes.length; n++) {
        if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
            if (str) str += '.';
            str += this.aNodes[n].id;
        }
    }
    this.setCookie('co' + this.obj, str);
};
dTree.prototype.isOpen = function (id) {
    var aOpen = this.getCookie('co' + this.obj).split('.');
    for (var n = 0; n < aOpen.length; n++)
        if (aOpen[n] == id) return true;
    return false;
};
if (!Array.prototype.push) {
    Array.prototype.push = function array_push() {
        for (var i = 0; i < arguments.length; i++)
            this[this.length] = arguments[i];
        return this.length;
    }
};
if (!Array.prototype.pop) {
    Array.prototype.pop = function array_pop() {
        lastElement = this[this.length - 1];
        this.length = Math.max(this.length - 1, 0);
        return lastElement;
    }
};
var _SHAPE = [];
_SHAPE["roundrect"] = [];
_SHAPE["rect"] = [];
_SHAPE["oval"] = [];
_SHAPE["diamond"] = [];
_SHAPE["line"] = [];
_SHAPE["polyline"] = [];
_SHAPE["polylinenolabel"] = [];
_SHAPE["oval"]["demo"] = '<v:Oval id="demoOval" title="圆形" style="position:relative;left:0px;top:0px;width:100px;height:40px;z-index:9" strokecolor="red" strokeweight="1">' + '<v:shadow id="demoOvalShadow" on="T" type="single" color="#b3b3b3" offset="5px,5px"/>' + '<v:extrusion id="demoOvalExt" on="false" backdepth="20" />' + '<v:fill id="demoOvalFill" type="gradient" color="white" color2="white" />' + '<v:TextBox id="demoOvalText" inset="2pt,5pt,2pt,5pt" style="text-align:center; color:red; font-size:9pt;">示例</v:TextBox>' + '</v:Oval>';
_SHAPE["oval"]["val"] = '<v:Oval id="{id}" title="{title}" sc="{sc}" fsc="{fsc}" st="{st}" typ="Proc" style="position:absolute;left:{l};top:{t};width:{w};height:{h};z-index:{z}"" strokecolor="{sc}" strokeweight="{sw}" ondblclick=\'editProc(this.id);\' >' + '<v:shadow on="{shadowenable}" type="single" color="{shadowcolor}" offset="5px,5px"/>' + '<v:extrusion on="{3denable}" backdepth="{3ddepth}" />' + '<v:fill type="gradient" color="{sc1}" color2="{sc2}" />' + '<v:TextBox id="{id}Text" inset="2pt,5pt,2pt,5pt" style="text-align:center; color:{tc}; font-size:{fs};">{text}</v:TextBox>' + '</v:Oval>';
_SHAPE["rect"]["demo"] = '<v:rect id="demoRect" title="方形" style="backgroup-color:#f0f0f0;z-index:0;position:relative;width:100px;height:40px;left:0px;top:0px;" strokecolor="blue" strokeweight="1">' + ' <v:shadow on="T" type="single" color="#b3b3b3" offset="5px,5px"/>' + ' <v:extrusion on="false" backdepth="20" />' + ' <v:fill type="gradient" color="white" color2="white" />' + ' <v:TextBox inset="2pt,5pt,2pt,5pt" style="text-align:center; color:blue; font-size:9pt;">示例</v:TextBox>' + '</v:rect>';
_SHAPE["rect"]["val"] = '<v:rect id="{id}" title="{title}" sc="{sc}" fsc="{fsc}" st="{st}" typ="Proc" style="z-index:{z};position:absolute;width:{w};height:{h};left:{l};top:{t};" strokecolor="{sc}" strokeweight="{sw}" ondblclick=\'editProc(this.id);\'>' + ' <v:shadow on="{shadowenable}" type="single" color="{shadowcolor}" offset="5px,5px"/>' + ' <v:extrusion on="{3denable}" backdepth="{3ddepth}" />' + ' <v:fill type="gradient" color="#dddddd" color2="#dddddd" />' + ' <v:TextBox id="{id}Text" inset="2pt,5pt,2pt,5pt" style="text-align:center; color:{tc}; font-size:{fs};">{text}</v:TextBox>' + '</v:rect>';
_SHAPE["roundrect"]["demo"] = '<v:RoundRect id="demoRoundRect" title="圆角形" style="position:relative;left:0px;top:0px;width:100px;height:40px;z-index:9"" strokecolor="blue" strokeweight="1">' + '<v:shadow id="demoRoundRectShadow" on="T" type="single" color="#b3b3b3" offset="5px,5px"/>' + '<v:extrusion id="demoRoundRectExt" on="false" backdepth="20" />' + '<v:fill id="demoRoundRectFill" type="gradient" color="white" color2="white" />' + '<v:TextBox id="demoRoundRectText" inset="2pt,5pt,2pt,5pt" style="text-align:center; color:blue; font-size:9pt;">示例</v:TextBox>' + '</v:RoundRect>';
_SHAPE["roundrect"]["val"] = '<v:RoundRect id="{id}" title="{title}" sc="{sc}" fsc="{fsc}" st="{st}" typ="Proc" style="position:absolute;left:{l};top:{t};width:{w};height:{h};z-index:{z}"" strokecolor="{sc}" strokeweight="{sw}" ondblclick=\'editProc(this.id);\'>' + '<v:shadow on="{shadowenable}" type="single" color="{shadowcolor}" offset="5px,5px"/>' + '<v:extrusion on="{3denable}" backdepth="{3ddepth}" />' + '<v:fill type="gradient" color="{sc1}" color2="{sc2}" />' + '<v:TextBox id="{id}Text" inset="2pt,5pt,2pt,5pt" style="text-align:center; color:{tc}; font-size:{fs};">{text}</v:TextBox>' + '</v:RoundRect>';
_SHAPE["diamond"]["demo"] = '<v:shape id="demoDiamond" title="菱形" type="#diamond" style="position:relative;left:0px;top:0px;width:100px;height:50px;z-index:9" strokecolor="blue" strokeweight="1">' + '<v:shadow on="T" type="single" color="#b3b3b3" offset="5px,5px"/>' + '<v:extrusion on="false" backdepth="20" />' + '<v:fill type="gradient" color="white" color2="white" />' + '<v:TextBox inset="5pt,10pt,5pt,5pt" style="text-align:center; color:blue; font-size:9pt;">示例</v:TextBox>' + '</v:shape>';
_SHAPE["diamond"]["val"] = '<v:shape type="#diamond" id="{id}" title="{title}" sc="{sc}" fsc="{fsc}" st="{st}" typ="Proc" style="position:absolute;width:{w};height:{h};left:{l};top:{t};z-index:{z}" strokecolor="{sc}" strokeweight="{sw}" ondblclick=\'editProc(this.id);\'>' + ' <v:shadow on="{shadowenable}" type="single" color="{shadowcolor}" offset="5px,5px"/>' + ' <v:extrusion on="{3denable}" backdepth="{3ddepth}" />' + ' <v:fill type="gradient" color="{sc1}" color2="{sc2}" />' + ' <v:TextBox id="{id}Text" inset="2pt,10pt,2pt,5pt" style="text-align:center; color:{tc}; font-size:{fs};">{text}</v:TextBox>' + '</v:shape>';
_SHAPE["line"]["demo"] = '<v:line id="demoLine" title="直线" style="z-index:0;position:relative;" from="0,0" to="100,0" strokecolor="blue" strokeweight="1">' + '<v:stroke id="demoLineArrow" StartArrow="" EndArrow="Classic"/>' + '<v:TextBox inset="5pt,1pt,5pt,5pt" style="text-align:center; color:blue; font-size:9pt;"></v:TextBox>' + '</v:line>'
_SHAPE["line"]["val"] = '<v:line id="{id}" title="{title}" sc="{sc}" fsc="{fsc}" typ="Step" style="z-index:{z};position:absolute;" {pt} strokecolor="{sc}" strokeweight="{sw}" onmousedown=\'objFocusedOn(this.id);\' ondblclick=\'editStep(this.id);\'>' + '<v:stroke id="{id}Arrow" StartArrow="{sa}" EndArrow="{ea}"/>' + '<v:TextBox id="{id}Text" inset="5pt,1pt,5pt,5pt" style="text-align:center; color:blue; font-size:9pt;">{cond}</v:TextBox>' + '</v:line>';
_SHAPE["polyline"]["demo"] = '<v:PolyLine id="demoPolyLine" title="折角线" filled="false" Points="0,20 50,0 100,20" style="z-index:0;position:relative;" strokecolor="blue" strokeweight="1">' + '<v:stroke id="demoPolyLineArrow" StartArrow="" EndArrow="Classic"/>' + '<v:TextBox inset="5pt,1pt,5pt,5pt" style="text-align:center; color:blue; font-size:9pt;"></v:TextBox>' + '</v:PolyLine>';
_SHAPE["polyline"]["val"] = '<v:PolyLine id="{id}" title="{title}" sc="{sc}" fsc="{fsc}" typ="Step" filled="false" Points="{pt}" style="z-index:{z};position:absolute;" strokecolor="{sc}" strokeweight="{sw}" onmousedown=\'objFocusedOn(this.id);\' ondblclick=\'editStep(this.id);\'>' + '<v:stroke id="{id}Arrow" StartArrow="{sa}" EndArrow="{ea}"/>' + '</v:PolyLine>' + '<div id={lid} title="{desc}" style="width:{w};height:{h};overflow:hidden;position:absolute;top:{y};left:{x};font-size:12px;z-index:1;" onmousedown="objFocusedOn(\'{id}\');">{text}</div>';
_SHAPE["polylinenolabel"]["val"] = '<v:PolyLine id="{id}" title="{title}" sc="{sc}" fsc="{fsc}" typ="Step" filled="false" Points="{pt}" style="z-index:{z};position:absolute;" strokecolor="{sc}" strokeweight="{sw}" onmousedown=\'objFocusedOn(this.id);\' ondblclick=\'editStep(this.id);\'>' + '<v:stroke id="{id}Arrow" StartArrow="{sa}" EndArrow="{ea}"/>' + '</v:PolyLine>';

function getShapeDemo(AName) {
    return _SHAPE[AName.toLowerCase()]["demo"];
}
function getShapeVal(AName) { return _SHAPE[AName.toLowerCase()]["val"]; }

function stuffShape(AStr, arr) { var re = /\{(\w+)\}/g; return AStr.replace(re, function (a, b) { return arr[b] }); };

document.write('<v:shapetype id="diamond" coordsize="12,12" path="m 6,0 l 0,6,6,12,12,6 x e"/>');

var _ToolBoxManager = [];

function TToolBox(id, caption, l, t, w, h, content, dir, expanded, mw, mh) {
    this.ID = id;
    this.Caption = caption;
    this.Left = l;
    this.Top = t;
    this.Width = w;
    this.MinWidth = mw ? mw : w;
    this.Height = h;
    this.MinHeight = mh ? mh : h;
    this.Content = content;
    this.TitleHeight = 20;
    this.Dir = dir;
    this.TitleBtn = dir == "down" ? new Array("down", "up") : new Array("up", "down");
    this.InnerObject = null;
    document.write(this);
    this.InnerObject = document.all(this.ID);
    this.Visible = true;
    this.VisibleEx = true;
    if (expanded == false) this.hideBox();
    _ToolBoxManager[_ToolBoxManager.length] = this;
};
TToolBox.prototype.hideBox = function () {
    var oTitle = document.all(this.ID + "_title");
    var oContent = document.all(this.ID + "_content");
    var oBottom = document.all(this.ID + "_bottom");
    var oImg = document.all(this.ID + "_img");
    this.InnerObject.style.height = this.TitleHeight;
    oImg.src = "image/" + this.TitleBtn[0] + ".gif";
    oImg.title = "单击展开工具栏";
    oContent.style.display = "none";
    oBottom.style.display = "none";
    oTitle.className = "trCss";
    if (this.Dir == "up") this.InnerObject.style.top = this.Top;
    this.Visible = false;
    setToolBoxTopMost(this);
};
TToolBox.prototype.showBox = function () {
    var oTitle = document.all(this.ID + "_title");
    var oContent = document.all(this.ID + "_content");
    var oBottom = document.all(this.ID + "_bottom");
    var oImg = document.all(this.ID + "_img");
    this.InnerObject.style.height = this.Height;
    oImg.src = "image/" + this.TitleBtn[1] + ".gif";
    oImg.title = "单击收缩工具栏";
    oContent.style.display = "block";
    oBottom.style.display = "block";
    oTitle.className = "trCss";
    if (this.Dir == "up") this.InnerObject.style.top = this.Top - this.Height + this.TitleHeight;
    this.Visible = true;
    setToolBoxTopMost(this);
};
TToolBox.prototype.showHideTool = function () {
    if (this.Visible)
        this.hideBox();
    else
        this.showBox();
};
TToolBox.prototype.setZIndex = function (i) {
    this.InnerObject.style.zIndex = i;
};
TToolBox.prototype.mouseDown = function () {
    if (event.button != 1) return;
    var obj = event.srcElement;
    setToolBoxTopMost(this);
    if (!obj.moveType) return;
    this.moveType = obj.moveType;
    this.InnerObject.setCapture();
    this.CurrentX = event.clientX - this.InnerObject.offsetLeft;
    this.CurrentY = event.clientY - this.InnerObject.offsetTop;
};
TToolBox.prototype.mouseMove = function () {
    switch (this.moveType) {
        case "m": this.Left = event.clientX - this.CurrentX;
            this.Top = event.clientY - this.CurrentY;
            this.InnerObject.style.left = this.Left;
            this.InnerObject.style.top = this.Top;
            break;
        case "s": this.Height = event.y - this.Top;
            if (this.Height < this.MinHeight) this.Height = this.MinHeight;
            this.InnerObject.style.height = this.Height;
            break;
        case "n": var bOffset = this.InnerObject.offsetTop + this.Height;
            this.Height = bOffset - event.y;
            if (this.Height < this.MinHeight) this.Height = this.MinHeight;
            this.Top = bOffset - this.Height;
            this.InnerObject.style.top = this.Top;
            this.InnerObject.style.height = this.Height;
            break;
        case "e": this.Width = event.x - this.Left;
            if (this.Width < this.MinWidth) this.Width = this.MinWidth;
            this.InnerObject.style.width = this.Width;
            break;
        case "nw": this.Width = event.x - this.Left;
            this.Height = event.y - this.Top;
            if (this.Height < this.MinHeight) this.Height = this.MinHeight;
            if (this.Width < this.MinWidth) this.Width = this.MinWidth;
            this.InnerObject.style.width = this.Width;
            this.InnerObject.style.height = this.Height;
            break;
    }
};
TToolBox.prototype.mouseUp = function () {
    this.moveType = "";
    this.InnerObject.releaseCapture();
    if (parseInt(this.InnerObject.style.top) < -10) {
        alert("工具栏上边界超出边界，将自动调整.");
        this.InnerObject.style.top = 30;
    }
};
//创建Toolbox 属性框
TToolBox.prototype.toString = function () {
    S = '<table id="' + this.ID + '" class="table1" style="position:absolute;left:' + this.Left + 'px;top:' + this.Top + 'px;width:' +
    this.Width + 'px;height:' + this.Height + 'px;z-index:3000" cellspacing="0" cellpadding="0" border="0" onmousedown="' + this.ID + '.mouseDown();" ' + 'onmousemove="' + this.ID + '.mouseMove();" onmouseup="' + this.ID + '.mouseUp();">';
    if (this.Dir == "down") {
        S += '<tr id="' + this.ID + '_title" height="' + this.TitleHeight + '" class="trCss"; style="cursor:move;"><td colspan="2"  title="双击可以展开/收缩工具栏，按住左键移动位置" ' + 'ondblclick="' + this.ID + '.showHideTool();"><table width="100%" class="table" height="100%" cellspacing="0" cellpadding="0" border="0"><tr><td width="99%" moveType="m">&nbsp;<font color="#000000" moveType="m">' + this.Caption + '</font></td><td width="1%"><img id="' + this.ID + '_img" title="单击收缩工具栏" src="image/' + this.TitleBtn[1] + '.gif" style="cursor:hand;" onclick="' + this.ID + '.showHideTool();" height="14" width="14" border="0"></td></tr></table></td></tr>' + '<tr id="' + this.ID + '_content"><td valign="top">' + this.Content + '&nbsp;</td><td width="2" style="cursor:E-resize;" moveType="e"></td></tr>' + '<tr id="' + this.ID + '_bottom" height="2"><td style="cursor:S-resize;" moveType="s"></td><td style="cursor:NW-resize;" moveType="nw"></td</tr>';
    }
    else
        S += '<tr id="' + this.ID + '_bottom" height="2"><td style="cursor:N-resize;" moveType="n"></td><td></td</tr>' + '<tr id="' + this.ID + '_content"><td valign="top">' + this.Content + '&nbsp;</td><td width="2" style="cursor:E-resize;" moveType="e"></td></tr>' + '<tr id="' + this.ID + '_title" height="' + this.TitleHeight + '" bgcolor="#0066FF" style="cursor:move;"><td colspan="2" title="双击可以展开/收缩工具栏，按住左键移动位置" ' + 'ondblclick="' + this.ID + '.showHideTool();"><table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0"><tr><td width="99%" moveType="m">&nbsp;<font color="#FFFFFF" moveType="m">' + this.Caption + '</font></td><td width="1%"><img id="' + this.ID + '_img" title="单击收缩工具栏" src="image/' + this.TitleBtn[1] + '.gif" style="cursor:hand;" onclick="' + this.ID + '.showHideTool();" height="14" width="14" border="0"></td></tr></table></td></tr>';
    S += '</table>';
    return S;
};
function TToolPanel(id, l, t, w, h, content, mw) {
    this.ID = id;
    this.Left = l;
    this.Top = t;
    this.Width = w;
    this.MinWidth = mw ? mw : w;
    this.Height = h;
    this.Content = content;
    this.InnerObject = null;
    document.write(this);
    this.InnerObject = document.all(this.ID);
    _ToolBoxManager[_ToolBoxManager.length] = this;
};
TToolPanel.prototype.setZIndex = function (i) {
    this.InnerObject.style.zIndex = i;
};
TToolPanel.prototype.toString = function () {
    S = '<table id="' + this.ID + '" class="toolbox" style="position:absolute;left:' + this.Left + 'px;top:' + this.Top + 'px;width:' +
    this.Width + 'px;height:' + this.Height + 'px;z-index:3000" cellspacing="0" cellpadding="0" border="0" onmousedown="' + this.ID + '.mouseDown();" ' + 'onmousemove="' + this.ID + '.mouseMove();" onmouseup="' + this.ID + '.mouseUp();">' + '<tr><td width="8" style="cursor:move;" moveType="m"><img moveType="m" src="image/tb_title.gif" height="25" width="5" border="0"></td><td>' + this.Content + '</td</tr>' + '</table>';
    return S;
};
TToolPanel.prototype.mouseDown = function () {
    if (event.button != 1) return;
    var obj = event.srcElement;
    if (!obj.moveType) return;
    this.moveType = obj.moveType;
    this.InnerObject.setCapture();
    this.CurrentX = event.x - this.InnerObject.offsetLeft;
    this.CurrentY = event.y - this.InnerObject.offsetTop;
    setToolBoxTopMost(this);
};
TToolPanel.prototype.mouseMove = function () {
    switch (this.moveType) {
        case "m": this.Left = event.x - this.CurrentX;
            this.Top = event.y - this.CurrentY
            this.InnerObject.style.left = this.Left;
            this.InnerObject.style.top = this.Top;
            break;
    }
};
TToolPanel.prototype.mouseUp = function () {
    this.moveType = "";
    this.InnerObject.releaseCapture();
    if (parseInt(this.InnerObject.style.top) < -10) {
        alert("工具栏上边界超出边界，将自动调整.");
        this.InnerObject.style.top = 0;
    }
};
function setToolBoxTopMost(AToolBox) {
    for (var i = 0; i < _ToolBoxManager.length; i++)
        _ToolBoxManager[i].setZIndex(3000);
    AToolBox.setZIndex(3001);
};
function TProc(AFlow, id, st) {
    var idPerfix = '';
    this.ObjType = "Proc";
    this.Flow = AFlow;
    this.ID = id;
    this.ShapeType = st;
    this.runType = "";
    if (st) {
        this.ProcType = this.getProcType();
    }
    idPerfix = 'p';
    if (this.ProcType == 'andjoin') {
        idPerfix = 'j';
    }
    if (this.ProcType == 'fork') {
        idPerfix = 'f';
    }
    if (this.ProcType != 'andjoin' && this.ProcType != 'fork') {
        idPerfix = '';
    }
    if (this.ID == undefined) {
        this.ID = this.Flow.getMaxProcID(idPerfix);
    }
    this.Text = "" + this.ID;
    if (this.ProcType == 'andjoin') {
        this.Text = this.Text.replace('j', '汇聚');
    }
    else
        if (this.ProcType == 'fork') {
            this.Text = this.Text.replace('f', '分支');
        }
        else {
            this.Text = this.Text.replace('p', '节点');
        }
    this.Width = "50";
    this.Height = "50";
    this.X = "50";
    this.Y = "50";
    this.TextWeight = "9pt";
    this.StrokeWeight = "1";
    this.zIndex = 1;
    this.InnerObject = null;
    this.MoveType = "";
    this.actFlag = "";
    this.WaitTime = "";
    this.SelectExit = "1";
    this.SameCredit = "1";
    this.WarnType = '';
    this.Executer = '';
    this.hExecuter = '';
    this.Aidancer = '';
    this.hAidancer = '';
    this.TimeLimit = '';
}
TProc.prototype.getInnerObject = function () {
    if (this.InnerObject == null) {
        this.InnerObject = document.all(this.ID);
    }
    return this.InnerObject;
}
TProc.prototype.setFocus = function () {
    this.getInnerObject.StrokeColor = this.Flow.Config.ProcFocusedStrokeColor;
}
TProc.prototype.lostFocus = function () {
    this.getInnerObject.StrokeColor = (this.ProcType == "NormalProc") ? this.Flow.Config.ProcColor : this.Flow.Config._ProcColor;
}
TProc.prototype.doClick = function () {
    this.Flow.selectObject(this.ID, "Proc");
}
TProc.prototype.mouseDown = function () {
    var rightSide = (parseInt(this.X) + parseInt(this.Width) - event.x <= 2);
    var bottomSide = (parseInt(this.Y) + parseInt(this.Height) - event.y <= 2);
    if (rightSide && bottomSide) {
        this.MoveType = "nw";
    }
    else
        if (rightSide) {
            this.MoveType = "e";
        }
        else
            if (bottomSide) {
                this.MoveType = "n";
            }
            else {
                this.MoveType = "m";
            }
    this.getInnerObject.setCapture();
    switch (this.MoveType) {
        case "m": this.CurrentX = event.x - this.InnerObject.offsetLeft;
            this.CurrentY = event.y - this.InnerObject.offsetTop;
            break;
        case "front": case "back": if (_TOOLTYPE == "front") {
                this.Flow.brintToFront(this);
            }
            else {
                this.Flow.sendToBack(this);
            }
            this.getInnerObject.style.zIndex = this.zIndex;
            break;
    }
}
TProc.prototype.mouseMove = function () {
    switch (this.MoveType) {
        case "m": this.X = event.x - this.CurrentX;
            this.Y = event.y - this.CurrentY;
            if (this.X < 0) {
                this.X = 0;
            }
            if (this.Y < 30) {
                this.Y = 30;
            }
            this.InnerObject.style.left = this.X;
            this.InnerObject.style.top = this.Y;
            break;
        case "n": this.Height = event.y - this.Y;
            if (this.Height < 30) {
                this.Height = 30;
            }
            this.InnerObject.style.height = this.Height;
            break;
        case "e": this.Width = event.x - this.X;
            if (this.Width < 30) {
                this.Width = 30;
            }
            this.InnerObject.style.width = this.Width;
            break;
        case "nw": this.Width = event.x - this.X;
            this.Height = event.y - this.Y;
            if (this.Width < 30) {
                this.Width = 30;
            }
            if (this.Height < 30) {
                this.Height = 30;
            }
            this.InnerObject.style.width = this.Width;
            this.InnerObject.style.height = this.Height;
            break;
        default: var rightSide = (parseInt(this.X) + parseInt(this.Width) - event.x <= 2);
            var bottomSide = (parseInt(this.Y) + parseInt(this.Height) - event.y <= 2);
            if (rightSide && bottomSide) {
                this.getInnerObject.style.cursor = "NW-resize";
            }
            else
                if (rightSide) {
                    this.getInnerObject.style.cursor = "E-resize";
                }
                else
                    if (bottomSide) {
                        this.getInnerObject.style.cursor = "N-resize";
                    }
                    else {
                        this.getInnerObject.style.cursor = "hand";
                    }
            break;
    }
}
TProc.prototype.mouseUp = function () {
    if (this.MoveType != "") {
        this.getInnerObject.releaseCapture();
        if (this.MoveType == "nw") {
            if (parseInt(this.InnerObject.style.top) < -10) {
                alert("对象上边界超出，将自动调整.");
                this.InnerObject.style.top = 30;
            }
            if (parseInt(this.InnerObject.style.left) < -10) {
                alert("对象左边界超出，将自动调整.");
                this.InnerObject.style.left = 30;
            }
        }
    }
    this.MoveType = "";
}
TProc.prototype.clone = function (AProc) {
    this.ID = AProc.ID;
    this.Text = AProc.Text;
    this.ShapeType = AProc.ShapeType
    this.ProcType = AProc.ProcType;
    this.Width = AProc.Width;
    this.Height = AProc.Height;
    this.X = AProc.X;
    this.Y = AProc.Y;
    this.TextWeight = AProc.TextWeight;
    this.StrokeWeight = AProc.StrokeWeight;
    this.zIndex = AProc.zIndex;
    this.InnerObject = null;
    this.MoveType = "";
    this.WarnType = AProc.WarnType;
    this.SelectExit = AProc.SelectExit;
    this.SameCredit = AProc.SameCredit;
    this.Executer = AProc.Executer;
    this.Aidancer = AProc.Aidancer;
    this.TimeLimit = AProc.TimeLimit;
}
TProc.prototype.setPropValue = function (AProp, AValue) {
    switch (AProp) {
        case "ID": var oldID = this.ID;
            if (oldID == AValue) {
                return true;
            }
            if (this.Flow.IDExists(AValue)) {
                alert("编号[" + AValue + "]已经存在!");
                return false;
            }
            this.InnerObject.all(oldID + "Text").id = AValue + "Text";
            this.ID = AValue;
            this.InnerObject.id = AValue;
            this.Flow.changeProcID(oldID, AValue);
            break;
        case "X": this.X = AValue;
            this.InnerObject.style.left = AValue;
            break;
        case "Y": this.Y = AValue;
            this.InnerObject.style.top = AValue;
            break;
        case "Width": this.Width = AValue;
            this.InnerObject.style.width = AValue;
            break;
        case "Height": this.Height = AValue;
            this.InnerObject.style.height = AValue;
            break;
    }
}
TProc.prototype.toString = function () {
    var cl = this.Flow.Config;
    var nStockeColor, nTextColor;
    if (this.ProcType == 'begin' || this.ProcType == 'end') {
        nTextColor = cl._ProcTextColor;
        nStrokeColor = cl._ProcColor;
    }
    else {
        nTextColor = cl.ProcTextColor;
        nStrokeColor = cl.ProcColor;
    }
    var arrVal = new Array();
    arrVal["id"] = this.ID;
    arrVal["title"] = this.ID;
    arrVal["sc"] = nStrokeColor;
    arrVal["st"] = this.ProcType;
    arrVal["l"] = this.X;
    arrVal["t"] = this.Y;
    arrVal["w"] = this.Width;
    arrVal["h"] = this.Height;
    arrVal["z"] = this.zIndex;
    arrVal["sw"] = this.StrokeWeight;
    arrVal["fsc"] = cl.ProcFocusedStrokeColor;
    arrVal["shadowenable"] = cl.IsProcShadow;
    arrVal["shadowcolor"] = cl.ProcShadowColor;
    arrVal["3denable"] = cl.IsProc3D;
    arrVal["3ddepth"] = cl.Proc3DDepth;
    arrVal["sc1"] = cl.ProcColor1;
    arrVal["sc2"] = cl.ProcColor2;
    arrVal["tc"] = nTextColor;
    arrVal["fs"] = this.TextWeight;
    arrVal["text"] = this.Text;
    arrVal["af"] = this.actFlag;
    arrVal["wt"] = this.WaitTime;
    arrVal["ist"] = this.SelectExit;
    arrVal["isc"] = this.SameCredit;
    return stuffShape(getShapeVal(this.ShapeType), arrVal);
}
function TStep(AFlow, id) {
    this.ObjType = "Step";
    this.Flow = AFlow;
    this.ID = id;
    if (this.ID == undefined) {
        this.ID = this.Flow.getMaxStepID();
    }
    this.Text = "" + this.ID;
    this.ShapeType = "Line";
    this.FromProc = "";
    this.ToProc = "";
    this.Points = "";
    this.StartArrow = "none";
    this.EndArrow = "Classic";
    this.TextWeight = "9pt";
    this.StrokeWeight = "1";
    this.zIndex = 0;
    this.InnerObject = null;
    this.fromRelX = 0;
    this.fromRelY = 0;
    this.toRelX = 0;
    this.toRelY = 0;
    this.Label = new TLabel('lab' + this.ID);
    this.Cond = '';
    this.Event = '';
    this.Desc = '';
}
TStep.prototype.clone = function (AStep) {
    this.ID = AStep.ID;
    this.Text = AStep.Text;
    this.ShapeType = AStep.ShapeType;
    this.FromProc = AStep.FromProc;
    this.ToProc = AStep.ToProc;
    this.Points = AStep.Points;
    this.StartArrow = AStep.StartArrow;
    this.EndArrow = AStep.EndArrow;
    this.TextWeight = AStep.TextWeight;
    this.StrokeWeight = AStep.StrokeWeight;
    this.zIndex = AStep.zIndex;
    this.Points = AStep.Points;
    this.fromRelX = AStep.fromRelX;
    this.fromRelY = AStep.fromRelY;
    this.toRelX = AStep.toRelX;
    this.toRelY = AStep.toRelY;
    this.Label = AStep.Label;
    this.Cond = AStep.Cond;
    this.Event = AStep.Event;
    this.Desc = AStep.Desc;
}
TStep.prototype.setPropValue = function (AProp, AValue) {
    switch (AProp) {
        case "ID": var oldID = this.ID;
            if (oldID == AValue) {
                return true;
            }
            if (this.Flow.IDExists(AValue)) {
                alert("编号[" + AValue + "]已经存在!");
                return false;
            }
            this.InnerObject.all(oldID + "Text").id = AValue + "Text";
            this.InnerObject.all(oldID + "Arrow").id = AValue + "Arrow";
            this.ID = AValue;
            this.InnerObject.id = AValue;
            break;
        case "Points": this.Points = AValue;
            break;
        case "FromProc": this.FromProc = AValue;
            break;
        case "ToProc": this.ToProc = AValue;
            break;
    }
}
TStep.prototype.toString = function () {
    var StepHTML = '';
    var cl = this.Flow.Config;
    var arrVal = new Array();
    arrVal["id"] = this.ID;
    arrVal["title"] = this.ID + ':' + this.Text;
    arrVal["sc"] = cl.StepColor;
    arrVal["pt"] = this.getPath();
    arrVal["z"] = this.zIndex;
    arrVal["sw"] = this.StrokeWeight;
    arrVal["fsc"] = cl.StepFocusedStrokeColor;
    arrVal["sa"] = this.StartArrow;
    arrVal["ea"] = this.EndArrow;
    arrVal["cond"] = this.Cond;
    arrVal["text"] = this.Text;
    arrVal["lid"] = this.Label.ID;
    arrVal["x"] = this.Label.X;
    arrVal["y"] = this.Label.Y;
    arrVal["w"] = this.Label.Width;
    arrVal["h"] = this.Label.Height;
    arrVal["desc"] = this.Desc;
    return stuffShape(getShapeVal(this.ShapeType), arrVal);
}
TStep.prototype.getInnerObject = function () {
    if (this.InnerObject == null) {
        this.InnerObject = document.all(this.ID);
    }
    return this.InnerObject;
}
TStep.prototype.setFocus = function () {
    this.getInnerObject.StrokeColor = this.Flow.Config.StepFocusedStrokeColor;
}
TStep.prototype.lostFocus = function () {
    this.getInnerObject.StrokeColor = this.Flow.Config.StepColor;
}
TStep.prototype.doClick = function () {
    this.Flow.selectObject(this.ID, "Step");
}
function TTopFlow(AName) {
    this.name = AName;
    this.opType = '';
    this.Version = '';
    this.ID = "";
    this.Text = "";
    this.FileName = "";
    this.FormID = "";
    this.Modified = false;
    this.Steps = [];
    this.Procs = [];
    this.Labels = [];
    this.Width = 0;
    this.Height = 0;
    this.SelectedObject = null;
    this.Password = "";
    this.Config =
    {
        _ProcColor: "#FF0000", _ProcTextColor: "#FF0000", ProcColor: "#0000FF", ProcTextColor: "#0000FF", ProcFocusedStrokeColor: "#00AA00", IsProcShadow: "T", ProcShadowColor: "#B3B3B3", ProcColor1: "#FFFFFF", ProcColor2: "#FFFFFF", JoinColor: "#f0f0f0", IsProc3D: "F", Proc3DDepth: "20", StepFocusedStrokeColor: "#00AA00", StepColor: "#0000FF"
    }
}
TTopFlow.prototype.getInnerObject = function () {
    for (var i = 0; i < this.Procs.length; i++) {
        this.Procs[i].getInnerObject();
    }
    for (i = 0; i < this.Steps.length; i++) {
        this.Steps[i].getInnerObject();
    }
}
TTopFlow.prototype.selectObject = function (aID, aType) {
    this.unSelectObject();
    this.SelectedObject = (aType == "Proc") ? this.getProcByID(aID) : this.getStepByID(aID);
    this.SelectedObject.setFocus();
}
TTopFlow.prototype.unSelectObject = function () {
    if (this.SelectedObject != null) {
        this.SelectedObject.lostFocus();
    }
    this.SelectedObject = null;
}
TTopFlow.prototype.clear = function () {
    this.FileName = '';
    this.Steps.length = 0;
    this.Procs.length = 0;
}
TTopFlow.prototype.addProc = function (AProc) {
    if (this.Procs.length > 100) {
        alert("最多不允许超过100个任务!");
        return false;
    }
    this.Modified = true;
    this.Procs[this.Procs.length] = AProc;
}
TTopFlow.prototype.addStep = function (AStep) {
    this.Steps[this.Steps.length] = AStep;
    this.Modified = true;
}
TTopFlow.prototype.changeProcID = function (OldID, NewID) {
    var Step;
    for (var i = 0; i < this.Steps.length; i++) {
        Step = this.Steps[i];
        if (Step.FromProc == OldID) {
            Step.FromProc = NewID;
        }
        if (Step.ToProc == OldID) {
            Step.ToProc = NewID;
        }
    }
}
TTopFlow.prototype.getProcDataView = function (AProcID) {
    var arr = [], Step;
    for (var i = 0; i < this.Steps.length; i++) {
        Step = this.Steps[i];
        if (Step.ToProc == AProcID) {
            S = this.getProcByID(Step.FromProc).Text;
            arr[arr.length] = new Array(Step.ID, S, Step.Cond);
        }
    }
    return arr;
}
TTopFlow.prototype.DataView = function () {
    var Proc;
    arrDataView = [], arr = [];
    var i, j, u, k = 0;
    for (i = 0; i < this.Procs.length; i++) {
        Proc = this.Procs[i];
        arr.length = 0;
        arr = this.getProcDataView(Proc.ID);
        u = arr.length;
        if (u != undefined && u != null && u > 0) {
            for (j = 0; j < arr.length; j++) {
                arrDataView[k++] =
                {
                    "ProcID": Proc.ID, "ProcText": Proc.Text, "Idx": j + 1, "PreProcID": arr[j][0], "PreProcText": arr[j][1], "Cond": arr[j][2]
                }
            }
        }
    }
    return arrDataView;
}
TTopFlow.prototype.hasPriorProc = function (AProcID) {
    for (var i = 0; i < this.Steps.length; i++) {
        if (this.Steps[i].ToProc == AProcID) {
            return true;
        }
    }
    return false;
}
TTopFlow.prototype.hasNextProc = function (AProcID) {
    for (var i = 0; i < this.Steps.length; i++) {
        if (this.Steps[i].FromProc == AProcID) {
            return true;
        }
    }
    return false;
}
TTopFlow.prototype.validate = function () {
    var ErrMsg = [];
    WarnMsg = [];
    var Proc, PType;
    var iFork = 0, iJoin = 0;
    for (var i = 0; i < this.Procs.length; i++) {
        Proc = this.Procs[i];
        PType = (Proc.ProcType == "begin" ? "开始节点" : (Proc.ProcType == "end" ? "结束节点" : (Proc.ProcType == "fork" ? "分支节点" : ((Proc.ProcType == "andjoin" || Proc.ProcType == "unandjoin") ? "汇聚节点" : "任务节点"))));
        if (Proc.ProcType != "begin") {
            if (!this.hasPriorProc(Proc.ID)) {
                ErrMsg.push("[" + Proc.Text + "] - " + PType + "必须有输入路径");
            }
        }
        if (Proc.ProcType != "end") {
            if (!this.hasNextProc(Proc.ID)) {
                ErrMsg.push("[" + Proc.Text + "] - " + PType + "必须有输出路径");
            }
        }
        if (Proc.ProcType == 'andjoin' || Proc.ProcType == 'unandjoin') {
            iJoin++;
        }
        if (Proc.ProcType == 'fork') {
            iFork++;
        }
    }
    if (iJoin != iFork) {
        ErrMsg.push("[分支节点]和[汇聚节点]需要一一对应");
    }
    return ErrMsg.join("\n") + WarnMsg.join("\n");
}
TTopFlow.prototype.addProcXML = function (xmlDoc, jxml, oProc) {
    var procNode = null;
    var stepNode = null;
    var taskNode = null;
    var helpNode = null;
    var eventNode = null;
    var conditionNode = null;
    var actionNode = null;
    var stepDesc = null;
    switch (oProc.ProcType) {
        case 'begin': procNode = xmlDoc.createNode(1, "start-state", "");
            break;
        case 'first': procNode = xmlDoc.createNode(1, "task-node", "");
            this.createTaskNode(xmlDoc, procNode, oProc);
            break;
        case 'andsign': procNode = xmlDoc.createNode(1, "task-node", "");
            this.createTaskNode(xmlDoc, procNode, oProc);
            break;
        case 'unandsign': procNode = xmlDoc.createNode(1, "task-node", "");
            this.createTaskNode(xmlDoc, procNode, oProc);
            break;
        case 'connectsign': procNode = xmlDoc.createNode(1, "task-node", "");
            this.createTaskNode(xmlDoc, procNode, oProc);
            break;
        case 'fork': procNode = xmlDoc.createNode(1, "fork", "");
            break;
        case 'andjoin': procNode = xmlDoc.createNode(1, "join", "");
            break;
        case 'unandjoin': procNode = xmlDoc.createNode(1, "join", "");
            break;
        case 'end': procNode = xmlDoc.createNode(1, "end-state", "");
            break;
        default: break;
    }
    if (procNode) {
        var taskName = oProc.ID;
        procNode.setAttribute("name", taskName);
        stepDesc = xmlDoc.createNode(1, "description", "");
        stepDesc.appendChild(xmlDoc.createTextNode(oProc.Text));
        procNode.appendChild(stepDesc);
        if (oProc.ProcType == 'fork') {
            var scriptNode = xmlDoc.createNode(1, "script", "");
            var variableNode = xmlDoc.createNode(1, "variable", "");
            var expressionNode = xmlDoc.createNode(1, "expression", "");
            variableNode.setAttribute("name", "transitionNames");
            variableNode.setAttribute("access", "write");
            scriptNode.appendChild(variableNode);
            scriptNode.appendChild(expressionNode);
            procNode.appendChild(scriptNode);
        }
        if (oProc.ProcType == 'unandjoin') {
            var teventNode = xmlDoc.createNode(1, "event", "");
            var tscriptNode = xmlDoc.createNode(1, "script", "");
            tscriptNode.appendChild(xmlDoc.createTextNode("org.jbpm.graph.node.Join join= (org.jbpm.graph.node.Join)node; join.setDiscriminator(true); "));
            teventNode.setAttribute("type", "node-enter");
            teventNode.appendChild(tscriptNode);
            procNode.appendChild(teventNode);
        }
        if (oProc.ProcType == 'end') {
            var endEvent = xmlDoc.createNode(1, 'event', "");
            endEvent.setAttribute("type", "node-enter");
            var endScriptAction = xmlDoc.createNode(1, 'action', '');
            endScriptAction.setAttribute('class', 'com.shcommit.tools.jbpm.handler.ProcessEnd');
            endScriptAction.setAttribute('name', 'processEnd');
            endEvent.appendChild(endScriptAction);
            procNode.appendChild(endEvent);
        }
        var outSteps = this.getOutSteps(oProc.ID);
        for (var i = 0; i < outSteps.length; i++) {
            stepNode = xmlDoc.createNode(1, "transition", "");
            stepNode.setAttribute("name", outSteps[i].ID);
            var toProc = this.getProcByID(outSteps[i].ToProc);
            var toProcType = toProc.ProcType;
            var toProcName = toProc.ID;
            stepNode.setAttribute("to", toProcName);
            if (outSteps[i].Cond && outSteps[i].Cond != '') {
                conditionNode = xmlDoc.createNode(1, "condition", "");
                conditionNode.setAttribute("expression", outSteps[i].Cond);
                stepNode.appendChild(conditionNode);
            }
            if (outSteps[i].Event && outSteps[i].Event != '') {
                var strEvent = '';
                var arrEvent = outSteps[i].Event.split('||');
                var params = '';
                var arrParam = null;
                var param = ''
                strEvent = arrEvent[0];
                actionNode = xmlDoc.createNode(1, "action", "");
                actionNode.setAttribute("class", "com.shcommit.tools.jbpm.handler." + strEvent);
                stepNode.appendChild(actionNode);
                if (arrEvent[1] && arrEvent[1] != '') {
                    var paramNode = null;
                    var arr = null;
                    var parainames = '';
                    var paramValue = '';
                    params = arrEvent[1];
                    arrParam = params.split(',');
                    for (var j = 0; j < arrParam.length; j++) {
                        paramValue = '';
                        arr = null;
                        if (arrParam[j] != '') {
                            arr = arrParam[j].split('=');
                            parainames = arr[0];
                            if (arr[1]) {
                                paramValue = arr[1];
                            }
                            if (parainames != '') {
                                paramNode = xmlDoc.createNode(1, parainames, "");
                                paramNode.appendChild(xmlDoc.createTextNode(paramValue));
                                actionNode.appendChild(paramNode);
                            }
                        }
                    }
                }
            }
            stepDesc = xmlDoc.createNode(1, "description", "");
            stepDesc.appendChild(xmlDoc.createTextNode(outSteps[i].Text));
            stepNode.appendChild(stepDesc);
            procNode.appendChild(stepNode);
        }
        jxml.appendChild(procNode);
    }
}
TTopFlow.prototype.createTaskNode = function (xmlDoc, procNode, oProc) {
    var taskNode = null;
    var helpNode = null;
    var personNode = null;
    var eventNode = null;
    var eventAction = null;
    taskNode = xmlDoc.createNode(1, "task", "");
    var taskName = oProc.ID;
    taskNode.setAttribute("name", taskName + '');
    taskNode.setAttribute("description", oProc.Text);
    personNode = xmlDoc.createNode('Element', "assignment", "");
    if (oProc.hExecuter && oProc.hExecuter != '') {
        personNode.setAttribute("actor-id", '#{' + oProc.hExecuter + 'α' + oProc.ID + '}');
    }
    else {
        personNode.setAttribute("actor-id", '#{blankα' + oProc.ID + '}');
    }
    taskNode.appendChild(personNode);
    if (oProc.ProcType != 'first') {
        helpNode = xmlDoc.createNode(1, "task", "");
        helpNode.setAttribute("name", oProc.ID + "r");
        helpNode.setAttribute("description", oProc.Text + '(查阅)');
        helpNode.setAttribute("signalling", "false");
        personNode = xmlDoc.createNode('Element', "assignment", "");
        if (oProc.hAidancer && oProc.hAidancer != '') {
            personNode.setAttribute("actor-id", '#{' + oProc.hAidancer + 'α' + oProc.ID + 'r}');
        }
        else {
            personNode.setAttribute("actor-id", '#{blankα' + oProc.ID + 'r}');
        }
        helpNode.appendChild(personNode);
    }
    if (oProc.ProcType == 'connectsign') {
        eventNode = xmlDoc.createNode(1, "event", "");
        eventNode.setAttribute("type", "task-end");
        eventAction = xmlDoc.createNode(1, "action", "");
        eventAction.setAttribute("class", "com.shcommit.tools.jbpm.handler.ChuanTaskEnd");
        eventNode.appendChild(eventAction);
        taskNode.appendChild(eventNode);
    }
    procNode.appendChild(taskNode);
    if (helpNode) {
        procNode.appendChild(helpNode);
    }
    if (oProc.ProcType != 'first') {
        procNode.setAttribute("create-tasks", "false");
        if (oProc.ProcType == 'connectsign' || oProc.ProcType == 'andsign') {
        }
        if (oProc.ProcType == 'unjoinsign') {
            procNode.setAttribute("signal", "first-wait");
        }
        else {
            procNode.setAttribute("signal", "last-wait");
        }
        eventNode = xmlDoc.createNode(1, "event", "");
        eventNode.setAttribute("type", "node-enter");
        eventAction = xmlDoc.createNode(1, "action", "");
        eventAction.setAttribute("name", "createInstance");
        if (oProc.ProcType == 'connectsign') {
            eventAction.setAttribute("class", "com.shcommit.tools.jbpm.handler.CreateChuan");
        }
        else {
            eventAction.setAttribute("class", "com.shcommit.tools.jbpm.handler.CreateTaskInstanceConsign");
        }
        eventNode.appendChild(eventAction);
    }
    if (eventNode) {
        procNode.appendChild(eventNode);
    }
    if (oProc.ProcType == 'unandsign') {
        eventNode = xmlDoc.createNode(1, "event", "");
        eventNode.setAttribute("type", "task-end");
        eventAction = xmlDoc.createNode(1, "action", "");
        eventAction.setAttribute("name", "endTaskInstance");
        eventAction.setAttribute("class", "com.shcommit.tools.jbpm.handler.TaskEndConsign");
        eventNode.appendChild(eventAction);
    }
    if (eventNode) {
        procNode.appendChild(eventNode);
    }
}
TTopFlow.prototype.getProcByID = function (id) {
    for (var i = 0; i < this.Procs.length; i++) {
        if (this.Procs[i].ID == id) {
            return this.Procs[i];
        }
    }
    return null;
}
TTopFlow.prototype.getStepByID = function (id) {
    for (var i = 0; i < this.Steps.length; i++) {
        if (this.Steps[i].ID == id) {
            return this.Steps[i];
        }
    }
    return null;
}
TTopFlow.prototype.getRightProc = function (id) {
    var p = this.Procs[0];
    var r = 0;
    var obj = null;
    var objLeft = 0;
    for (var i = 0; i < this.Procs.length; i++) {
        obj = document.getElementById(this.Procs[i].ID);
        objLeft = parseInt(obj.style.left.replace('px', '')) + parseInt(obj.style.width.replace('px', ''));
        if (objLeft > r) {
            r = objLeft;
            p = this.Procs[i];
        }
    }
    return p;
}
TTopFlow.prototype.getBottomProc = function (id) {
    var p = this.Procs[0];
    var r = 0;
    var obj = null;
    var objTop = 0;
    for (var i = 0; i < this.Procs.length; i++) {
        obj = document.getElementById(this.Procs[i].ID);
        objTop = parseInt(obj.style.top.replace('px', '')) + parseInt(obj.style.height.replace('px', ''));
        if (objTop > r) {
            r = objTop;
            p = this.Procs[i];
        }
    }
    return p;
}
TTopFlow.prototype.getProcAtXY = function (x, y) {
    var Proc;
    for (var i = 0; i < this.Procs.length; i++) {
        Proc = this.Procs[i];
        if (x >= parseInt(Proc.X) && x <= parseInt(Proc.X) + parseInt(Proc.Width) && y >= parseInt(Proc.Y) && y <= parseInt(Proc.Y) + parseInt(Proc.Height)) {
            return Proc;
        }
    }
    return null;
}
TTopFlow.prototype.IDExists = function (id) {
    var obj = _FLOW.getProcByID(id);
    if (obj != null) {
        return true;
    }
    var obj = _FLOW.getStepByID(id);
    return (obj != null);
}
TTopFlow.prototype.StepPathExists = function (FromProc, ToProc) {
    var Step;
    for (var i = 0; i < this.Steps.length; i++) {
        Step = this.Steps[i];
        if (Step.FromProc == FromProc && Step.ToProc == ToProc) {
            return Step;
        }
    }
    return null;
}
TTopFlow.prototype.deleteProcByID = function (id) {
    this.Modified = true;
    for (var i = 0; i < this.Procs.length; i++) {
        if (this.Procs[i].ID == id) {
            this.Procs.splice(i, 1);
        }
    }
    for (i = this.Steps.length - 1; i >= 0; i--) {
        if (this.Steps[i].FromProc == id || this.Steps[i].ToProc == id) {
            this.Steps.splice(i, 1);
        }
    }
}
TTopFlow.prototype.deleteStepByID = function (id) {
    this.Modified = true;
    for (var i = 0; i < this.Steps.length; i++) {
        if (this.Steps[i].ID == id) {
            this.Steps.splice(i, 1);
        }
    }
}
TTopFlow.prototype.getMaxZIndex = function () {
    var m = 0;
    for (var i = 0; i < this.Procs.length; i++) {
        m = Math.max(m, this.Procs[i].zIndex);
    }
    for (i = 0; i < this.Steps.length; i++) {
        m = Math.max(m, this.Steps[i].zIndex);
    }
    return m;
}
TTopFlow.prototype.getMinZIndex = function () {
    var m = 0;
    for (var i = 0; i < this.Procs.length; i++) {
        m = Math.min(m, this.Procs[i].zIndex);
    }
    for (i = 0; i < this.Steps.length; i++) {
        m = Math.min(m, this.Steps[i].zIndex);
    }
    return m;
}
TTopFlow.prototype.brintToFront = function (obj) {
    this.Modified = true;
    obj.zIndex = this.getMaxZIndex() + 1;
}
TTopFlow.prototype.sendToBack = function (obj) {
    this.Modified = true;
    obj.zIndex = this.getMinZIndex() - 1;
}
TTopFlow.prototype.getMaxProcID = function (st) {
    if (!st) {
        st = 'p';
    }
    var s = "";
    var i, j, u = this.Procs.length;
    for (i = 0; i <= u; i++) {
        s = st + i;
        for (j = 0; j < u; j++) {
            if (this.Procs[j].ID == s) {
                break;
            }
        }
        if (j == u) {
            break;
        }
    }
    return s;
}
TTopFlow.prototype.getProcNewId = function (st, obj) {
    if (!st) {
        st = 'p';
    }
    var s = "";
    var idPostfix = '';
    var i, j, u = this.Procs.length;
    for (i = 0; i <= u; i++) {
        switch (obj.ProcType) {
            case 'unandsign': case 'unandjoin': idPostfix = 'u';
                break;
            case 'connectsign': idPostfix = 'c';
                break;
            default: idPostfix = '';
                break;
        }
        s = st + i + idPostfix;
        if (obj.ID == s) {
            break;
        }
        for (j = 0; j < u; j++) {
            if (this.Procs[j].ID == s) {
                break;
            }
        }
        if (j == u) {
            break;
        }
    }
    return s;
}
TTopFlow.prototype.getMaxStepID = function () {
    var s = "";
    var i, j, u = this.Steps.length;
    for (i = 0; i <= u; i++) {
        s = "s" + i;
        for (j = 0; j < u; j++) {
            if (this.Steps[j].ID == s) {
                break;
            }
        }
        if (j == u) {
            break;
        }
    }
    return s;
}
TTopFlow.prototype.ProcString = function () {
    var S = "", i;
    for (i = 0; i < this.Procs.length; i++) {
        S += this.Procs[i];
    }
    return S;
}
TTopFlow.prototype.StepString = function () {
    var S = "", i;
    for (i = 0; i < this.Steps.length; i++) {
        S += this.Steps[i];
    }
    return S;
}
TTopFlow.prototype.toString = function () {
    return this.ProcString() + this.StepString();
}
TStep.prototype.getPath = function () {
    if (this.Points != null && this.Points != "") {
        return this.Points;
    }
    var fromProc = document.getElementById(this.FromProc), toProc = document.getElementById(this.ToProc);
    if (fromProc == null || toProc == null) {
        return '';
    }
    var fromW = parseInt(fromProc.style.width);
    var fromH = parseInt(fromProc.style.height);
    var toW = parseInt(toProc.style.width);
    var toH = parseInt(toProc.style.height);
    var fromX = parseInt(fromProc.style.left);
    var fromY = parseInt(fromProc.style.top);
    var toX = parseInt(toProc.style.left);
    var toY = parseInt(toProc.style.top);
    if (this.FromProc == this.ToProc) {
        return this.getSelfPath(fromX, fromY, fromW, fromH);
    }
    if (ifRepeatProc(fromX, fromY, fromW, fromH, toX, toY, toW, toH)) {
        return "";
    }
    else
        if (this.ShapeType == "PolyLine") {
            return this.getLinePath(fromX, fromY, fromW, fromH, toX, toY, toW, toH);
        }
        else
            return this.Points;
}
TStep.prototype.reGetPath = function () {
    var fromProc = document.getElementById(this.FromProc), toProc = document.getElementById(this.ToProc);
    if (fromProc == null || toProc == null) {
        return '';
    }
    var fromW = parseInt(fromProc.style.width);
    var fromH = parseInt(fromProc.style.height);
    var toW = parseInt(toProc.style.width);
    var toH = parseInt(toProc.style.height);
    var fromX = parseInt(fromProc.style.left);
    var fromY = parseInt(fromProc.style.top);
    var toX = parseInt(toProc.style.left);
    var toY = parseInt(toProc.style.top);
    if (this.FromProc == this.ToProc) {
        return this.getSelfPath(fromX, fromY, fromW, fromH);
    }
    if (ifRepeatProc(fromX, fromY, fromW, fromH, toX, toY, toW, toH)) {
        return "";
    }
    else
        if (this.ShapeType == "PolyLine") {
            return this.getLinePath(fromX, fromY, fromW, fromH, toX, toY, toW, toH);
        }
        else {
            return this.Points;
        }
}
TStep.prototype.getSelfPath = function (ProcX, ProcY, ProcW, ProcH) {
    var constLength = 10;
    point0X = ProcX + ProcW - constLength;
    point0Y = ProcY + ProcH;
    point1X = point0X;
    point1Y = point0Y + constLength;
    point2X = ProcX + ProcW + constLength;
    point2Y = point1Y;
    point3X = point2X;
    point3Y = point0Y - constLength;
    point4X = ProcX + ProcW;
    point4Y = point3Y;
    return point0X + ',' + point0Y + ' ' + point1X + ',' + point1Y + ' ' + point2X + ',' + point2Y + ' ' + point3X + ',' + point3Y + ' ' + point4X + ',' + point4Y;
}
TStep.prototype.getLinePath = function (fromProcX, fromProcY, fromProcW, fromProcH, toProcX, toProcY, toProcW, toProcH) {
    var fromX, fromY, toX, toY, fromRelX, fromRelY, toRelX, toRelY;
    if (fromProcY + fromProcH < toProcY) {
        if (fromProcX + fromProcW < toProcX) {
            fromX = fromProcX + fromProcW;
            fromY = fromProcY + fromProcH;
            toX = toProcX;
            toY = toProcY;
            fromRelX = 1;
            fromRelY = 1;
            toRelX = 0;
            toRelY = 0;
        }
        else
            if (fromProcX > toProcX + toProcW) {
                fromX = fromProcX;
                fromY = fromProcY + fromProcH;
                toX = toProcX + toProcW;
                toY = toProcY;
                fromRelX = 0;
                fromRelY = 1;
                toRelX = 1;
                toRelY = 0;
            }
            else {
                fromX = fromProcX + parseInt(fromProcW / 2);
                fromY = fromProcY + fromProcH;
                toX = toProcX + parseInt(toProcW / 2);
                toY = toProcY;
                fromRelX = 0.5;
                fromRelY = 1;
                toRelX = 0.5;
                toRelY = 0;
            }
    }
    else
        if (fromProcY > toProcY + toProcH) {
            if (fromProcX + fromProcW < toProcX) {
                fromX = fromProcX + fromProcW;
                fromY = fromProcY;
                toX = toProcX;
                toY = toProcY + toProcH;
                fromRelX = 1;
                fromRelY = 0;
                toRelX = 0;
                toRelY = 1;
            }
            else
                if (fromProcX > toProcX + toProcW) {
                    fromX = fromProcX;
                    fromY = fromProcY;
                    toX = toProcX + toProcW;
                    toY = toProcY + toProcH;
                    fromRelX = 0;
                    fromRelY = 0;
                    toRelX = 1;
                    toRelY = 1;
                }
                else {
                    fromX = fromProcX + parseInt(fromProcW / 2);
                    fromY = fromProcY;
                    toX = toProcX + parseInt(toProcW / 2);
                    toY = toProcY + toProcH;
                    fromRelX = 0.5;
                    fromRelY = 0;
                    toRelX = 0.5;
                    toRelY = 1;
                }
        }
        else
            if (fromProcX + fromProcW < toProcX) {
                fromX = fromProcX + fromProcW;
                fromY = fromProcY + parseInt(fromProcH / 2);
                toX = toProcX;
                toY = toProcY + parseInt(toProcH / 2);
                fromRelX = 1;
                fromRelY = 0.5;
                toRelX = 0;
                toRelY = 0.5;
            }
            else {
                fromX = fromProcX;
                fromY = fromProcY + parseInt(fromProcH / 2);
                toX = toProcX + toProcW;
                toY = toProcY + parseInt(toProcH / 2);
                fromRelX = 0;
                fromRelY = 0.5;
                toRelX = 1;
                toRelY = 0.5;
            }
    this.fromRelX = fromRelX;
    this.fromRelY = fromRelY;
    this.toRelX = toRelX;
    this.toRelY = toRelY;
    this.Points = fromX / 4 * 3 + 'pt,' + fromY / 4 * 3 + 'pt,' + toX / 4 * 3 + 'pt,' + toY / 4 * 3 + 'pt';
    return this.Points;
}
TStep.prototype.getPolyLinePath = function (fromProcX, fromProcY, fromProcW, fromProcH, toProcX, toProcY, toProcW, toProcH) {
    var fromCenterX = fromProcX + parseInt(fromProcW / 2);
    var fromCenterY = fromProcY + parseInt(fromProcH / 2);
    var toCenterX = toProcX + parseInt(toProcW / 2);
    var toCenterY = toProcY + parseInt(toProcH / 2);
    point2X = fromCenterX;
    point2Y = toCenterY;
    if (toCenterX > fromCenterX) {
        absY = toCenterY >= fromCenterY ? toCenterY - fromCenterY : fromCenterY - toCenterY;
        if (parseInt(fromProcH / 2) >= absY) {
            point1X = fromProcX + fromProcW;
            point1Y = toCenterY;
            point2X = point1X;
            point2Y = point1Y;
        }
        else {
            point1X = fromCenterX;
            point1Y = fromCenterY < toCenterY ? fromProcY + fromProcH : fromProcY;
        }
        absX = toCenterX - fromCenterX;
        if (parseInt(fromProcW / 2) >= absX) {
            point3X = fromCenterX;
            point3Y = fromCenterY < toCenterY ? toProcY : toProcY + toProcH;
            point2X = point3X;
            point2Y = point3Y;
        }
        else {
            point3X = toProcX;
            point3Y = toCenterY;
        }
    }
    if (toCenterX < fromCenterX) {
        absY = toCenterY >= fromCenterY ? toCenterY - fromCenterY : fromCenterY - toCenterY;
        if (parseInt(fromProcH / 2) >= absY) {
            point1X = fromProcX;
            point1Y = toCenterY;
            point2X = point1X;
            point2Y = point1Y;
        }
        else {
            point1X = fromCenterX;
            point1Y = fromCenterY < toCenterY ? fromProcY + fromProcH : fromProcY;
        }
        absX = fromCenterX - toCenterX;
        if (parseInt(fromProcW / 2) >= absX) {
            point3X = fromCenterX;
            point3Y = fromCenterY < toCenterY ? toProcY : toProcY + toProcH;
            point2X = point3X;
            point2Y = point3Y;
        }
        else {
            point3X = toProcX + toProcW;
            point3Y = toCenterY;
        }
    }
    if (toCenterX == fromCenterX) {
        point1X = fromCenterX;
        point1Y = fromCenterY > toCenterY ? fromProcY : fromProcY + fromProcH;
        point3X = fromCenterX;
        point3Y = fromCenterY > toCenterY ? toProcY + toProcH : toProcY;
        point2X = point3X;
        point2Y = point3Y;
    }
    if (toCenterY == fromCenterY) {
        point1X = fromCenterX > toCenterX ? fromProcX : fromProcX + fromProcW;
        point1Y = fromCenterY;
        point3Y = fromCenterY;
        point3X = fromCenterX > toCenterX ? toProcX + toProcW : toProcX;
        point2X = point3X;
        point2Y = point3Y;
    }
    return point1X + ',' + point1Y + ' ' + point2X + ',' + point2Y + ' ' + point3X + ',' + point3Y;
}
function ifRepeatProc(fromX, fromY, fromW, fromH, toX, toY, toW, toH) {
    return (fromX + fromW >= toX) && (fromY + fromH >= toY) && (toX + toW >= fromX) && (toY + toH >= fromY);
}
function TLabel(id) {
    this.ID = id;
    this.Text = "";
    this.Desc = "";
    this.Step = null;
    this.X = 0;
    this.Y = 0;
    this.Width = "40px";
    this.Height = "20px";
    this.bgColor = "#ffffff";
}
TProc.prototype.getProcType = function () {
    switch (this.ShapeType) {
        case "rect": return 'andjoin';
            break;
        case "roundrect": return 'andsign';
            break;
        case "diamond": return 'fork';
            break;
        default: break;
    }
}
TStep.prototype.toStringWithoutLabel = function () {
    var StepHTML = '';
    var cl = this.Flow.Config;
    var arrVal = new Array();
    arrVal["id"] = this.ID;
    arrVal["title"] = this.ID + ':' + this.Text;
    arrVal["sc"] = cl.StepColor;
    arrVal["pt"] = this.getPath();
    arrVal["z"] = this.zIndex;
    arrVal["sw"] = this.StrokeWeight;
    arrVal["fsc"] = cl.StepFocusedStrokeColor;
    arrVal["sa"] = this.StartArrow;
    arrVal["ea"] = this.EndArrow;
    arrVal["cond"] = this.Cond;
    arrVal["text"] = this.Text;
    return stuffShape(getShapeVal('polylinenolabel'), arrVal);
}
TTopFlow.prototype.getOutSteps = function (AProcID) {
    var Steps = [];
    for (var i = 0; i < this.Steps.length; i++) {
        if (this.Steps[i].FromProc == AProcID) {
            Steps[Steps.length] = this.Steps[i];
        }
    }
    return Steps;
}
TTopFlow.prototype.getAllInStepId = function (AProcID) {
    var strId = '';
    for (var i = 0; i < this.Steps.length; i++) {
        if (this.Steps[i].ToProc == AProcID) {
            strId += ',' + this.Steps[i].ID;
        }
    }
    strId = strId.replace(',', '');
    return strId;
}
TTopFlow.prototype.isExitName = function (val) {
    var isExit = false;
    for (var i = 0; i < this.Steps.length; i++) {
        if (this.Steps[i].Text.toLowerCase() == val.toLowerCase()) {
            isExit = true;
        }
    }
    for (var i = 0; i < this.Procs.length; i++) {
        if (this.Procs[i].Text.toLowerCase() == val.toLowerCase()) {
            isExit = true;
        }
    }
    return isExit;
}
TTopFlow.prototype.createNew = function (id, name) {
    this.ID = id;
    this.Text = name;
    this.clear();
    Proc = new TProc(this, "begin");
    Proc.Text = "开始";
    Proc.ShapeType = "Oval";
    Proc.ProcType = "begin";
    Proc.Width = "40";
    Proc.Height = "40";
    Proc.X = "60";
    Proc.Y = "160";
    this.addProc(Proc);
    Proc = new TProc(this, "end");
    Proc.Text = "结束";
    Proc.ShapeType = "Oval";
    Proc.ProcType = "end";
    Proc.Width = "40";
    Proc.Height = "40";
    Proc.X = "210";
    Proc.Y = "260";
    this.addProc(Proc);
    Proc = new TProc(this, "first");
    Proc.Text = "第一个节点";
    Proc.ShapeType = "roundrect";
    Proc.Executer = "流程启动人";
    Proc.hExecuter = "starter";
    Proc.ProcType = "first";
    Proc.X = "180";
    Proc.Y = "160";
    Proc.Width = "100";
    Proc.Height = "40";
    this.addProc(Proc);
    Step = new TStep(this, "s0");
    Step.Text = "流程开始";
    Step.FromProc = "begin";
    Step.ToProc = "first";
    Step.ShapeType = "PolyLine";
    Step.fromRelX = 1;
    Step.fromRelY = 0.5;
    Step.toRelX = 0;
    Step.toRelY = 0.5;
    Step.Points = "75pt,135pt,135pt,135pt";
    Step.Label.X = "120";
    Step.Label.Y = "190"
    Step.Label.Width = "60"
    this.addStep(Step);
};
TTopFlow.prototype.loadFromXML = function (viUrl, defID, defName, formId, view, jbpmDefId) {
    this.clear();
    this.FileName = defID;
    if (formId && formId != '') {
        this.FormID = formId;
    }
    var xmlDoc = new ActiveXObject('MSXML2.DOMDocument');

    xmlDoc.async = false;

    var url = viUrl;
    if (view) {
        url = viUrl;
    }
    if (jbpmDefId) {
        this.Version = jbpmDefId;
        this.opType = 'version';
        document.onmousemove = '';
    }
    var flag = xmlDoc.load(url);

    if (!flag) {
        this.createNew(defID, defName);
        return false;
    }
    var xmlRoot = xmlDoc.documentElement;
    this.Text = xmlRoot.getAttribute("text");
    this.Password = xmlRoot.getAttribute("password");
    this.ID = defID;
    if (xmlRoot.getAttribute("width")) {
        this.Width = xmlRoot.getAttribute("width")
    }
    if (xmlRoot.getAttribute("height")) {
        this.Height = xmlRoot.getAttribute("height")
    }
    var Procs = xmlRoot.getElementsByTagName("Procs").item(0);
    var id, oNode, Prop;
    for (i = 0; i < Procs.childNodes.length; i++) {
        var Proc = Procs.childNodes.item(i);
        Prop = Proc.getElementsByTagName("BaseProperties").item(0);
        id = Prop.getAttribute("id");
        oNode = new TProc(this, id);
        oNode.Text = Prop.getAttribute("text");
        oNode.ProcType = Prop.getAttribute("ProcType");
        oNode.SameCredit = Prop.getAttribute("SameCredit") ? Prop.getAttribute("SameCredit") : 1;
        oNode.WarnType = Prop.getAttribute("WarnType");
        oNode.Executer = Prop.getAttribute("Executer");
        oNode.Aidancer = Prop.getAttribute("Aidancer");
        oNode.hExecuter = Prop.getAttribute("hExecuter") ? Prop.getAttribute("hExecuter") : '';
        oNode.hAidancer = Prop.getAttribute("hAidancer") ? Prop.getAttribute("hAidancer") : '';
        oNode.TimeLimit = Prop.getAttribute("TimeLimit");
        Prop = Proc.getElementsByTagName("VMLProperties").item(0);
        oNode.ShapeType = Prop.getAttribute("shapetype");
        oNode.Width = Prop.getAttribute("width");
        oNode.Height = Prop.getAttribute("height");
        oNode.X = Prop.getAttribute("x");
        oNode.Y = Prop.getAttribute("y");
        oNode.TextWeight = Prop.getAttribute("textWeight");
        oNode.StrokeWeight = Prop.getAttribute("strokeWeight");
        oNode.zIndex = Prop.getAttribute("zIndex");
        if (oNode.zIndex == '')
            oNode.zIndex = this.getMinZIndex() - 1;
        this.addProc(oNode);
    }
    var Steps = xmlRoot.getElementsByTagName("Steps").item(0);
    for (i = 0; i < Steps.childNodes.length; i++) {
        var Step = Steps.childNodes.item(i);
        Prop = Step.getElementsByTagName("BaseProperties").item(0);
        id = Prop.getAttribute("id");
        oNode = new TStep(this, id);
        oNode.Text = Prop.getAttribute("text");
        oNode.FromProc = Prop.getAttribute("from");
        oNode.ToProc = Prop.getAttribute("to");
        oNode.Cond = Prop.getAttribute("Cond");
        oNode.Cond = oNode.Cond.replace(/\'/g, '"'); var et = Prop.getAttribute("Event"); if (!et) { et = ""; }
        oNode.Event = et;
        oNode.Desc = Prop.getAttribute("Desc");
        Prop = Step.getElementsByTagName("VMLProperties").item(0);
        oNode.Points = Prop.getAttribute("points");
        oNode.fromRelX = Prop.getAttribute("fromRelX");
        oNode.fromRelY = Prop.getAttribute("fromRelY");
        oNode.toRelX = Prop.getAttribute("toRelX");
        oNode.toRelY = Prop.getAttribute("toRelY");
        oNode.ShapeType = Prop.getAttribute("shapetype");
        oNode.StartArrow = Prop.getAttribute("startArrow");
        oNode.EndArrow = Prop.getAttribute("endArrow");
        oNode.StrokeWeight = Prop.getAttribute("strokeWeight");
        oNode.zIndex = Prop.getAttribute("zIndex");
        var LabProp = Step.getElementsByTagName("LabelProperties").item(0);
        if (LabProp) {
            id = LabProp.getAttribute("id");
            oLabel = new TLabel(id);
            oLabel.Text = Prop.getAttribute("text");
            oLabel.Desc = Prop.getAttribute("desc");
            oLabel.X = LabProp.getAttribute("x");
            oLabel.Y = LabProp.getAttribute("y");
            oLabel.Width = LabProp.getAttribute("width");
            oLabel.Height = LabProp.getAttribute("height");
            oNode.Label = oLabel;
        }
        if (oNode.zIndex == '')
            oNode.zIndex = this.getMinZIndex() - 1;
        this.addStep(oNode);
    }
    this.Modified = false;
    return true;
};

//从XML文件中载入流程图

TTopFlow.prototype.loadFromXMLString = function (AFileContent, defID) {
    this.clear();

    var xmlDoc = new ActiveXObject('MSXML2.DOMDocument');
    xmlDoc.async = false;
    var flag = false;
    if (AFileContent != null) {
        flag = xmlDoc.loadXML(AFileContent);
    }
    if (!flag) {
        alert('流程图载入失败!');
        this.createNew("");
        return false;
    }

    var xmlRoot = xmlDoc.documentElement;
    this.Text = defID;
    this.Password = "";
    this.ID = defID;
    if (xmlRoot.getAttribute("width")) {
        this.Width = xmlRoot.getAttribute("width")
    }
    if (xmlRoot.getAttribute("height")) {
        this.Height = xmlRoot.getAttribute("height")
    }
    var Procs = xmlRoot.getElementsByTagName("Procs").item(0);
    var id, oNode, Prop;
    for (i = 0; i < Procs.childNodes.length; i++) {
        var Proc = Procs.childNodes.item(i);
        Prop = Proc.getElementsByTagName("BaseProperties").item(0);
        id = Prop.getAttribute("id");
        oNode = new TProc(this, id);
        oNode.Text = Prop.getAttribute("text");
        oNode.ProcType = Prop.getAttribute("ProcType");
        oNode.SameCredit = Prop.getAttribute("SameCredit") ? Prop.getAttribute("SameCredit") : 1;
        oNode.WarnType = Prop.getAttribute("WarnType");
        oNode.Executer = Prop.getAttribute("Executer");
        oNode.Aidancer = Prop.getAttribute("Aidancer");
        oNode.hExecuter = Prop.getAttribute("hExecuter") ? Prop.getAttribute("hExecuter") : '';
        oNode.hAidancer = Prop.getAttribute("hAidancer") ? Prop.getAttribute("hAidancer") : '';
        oNode.TimeLimit = Prop.getAttribute("TimeLimit");
        Prop = Proc.getElementsByTagName("VMLProperties").item(0);
        oNode.ShapeType = Prop.getAttribute("shapetype");
        oNode.Width = Prop.getAttribute("width");
        oNode.Height = Prop.getAttribute("height");
        oNode.X = Prop.getAttribute("x");
        oNode.Y = Prop.getAttribute("y");
        oNode.TextWeight = Prop.getAttribute("textWeight");
        oNode.StrokeWeight = Prop.getAttribute("strokeWeight");
        oNode.zIndex = Prop.getAttribute("zIndex");
        if (oNode.zIndex == '')
            oNode.zIndex = this.getMinZIndex() - 1;
        this.addProc(oNode);
    }
    var Steps = xmlRoot.getElementsByTagName("Steps").item(0);
    for (i = 0; i < Steps.childNodes.length; i++) {
        var Step = Steps.childNodes.item(i);
        Prop = Step.getElementsByTagName("BaseProperties").item(0);
        id = Prop.getAttribute("id");
        oNode = new TStep(this, id);
        oNode.Text = Prop.getAttribute("text");
        oNode.FromProc = Prop.getAttribute("from");
        oNode.ToProc = Prop.getAttribute("to");
        oNode.Cond = Prop.getAttribute("Cond");
        oNode.Cond = oNode.Cond.replace(/\'/g, '"'); var et = Prop.getAttribute("Event"); if (!et) { et = ""; }
        oNode.Event = et;
        oNode.Desc = Prop.getAttribute("Desc");
        Prop = Step.getElementsByTagName("VMLProperties").item(0);
        oNode.Points = Prop.getAttribute("points");
        oNode.fromRelX = Prop.getAttribute("fromRelX");
        oNode.fromRelY = Prop.getAttribute("fromRelY");
        oNode.toRelX = Prop.getAttribute("toRelX");
        oNode.toRelY = Prop.getAttribute("toRelY");
        oNode.ShapeType = Prop.getAttribute("shapetype");
        oNode.StartArrow = Prop.getAttribute("startArrow");
        oNode.EndArrow = Prop.getAttribute("endArrow");
        oNode.StrokeWeight = Prop.getAttribute("strokeWeight");
        oNode.zIndex = Prop.getAttribute("zIndex");
        var LabProp = Step.getElementsByTagName("LabelProperties").item(0);
        if (LabProp) {
            id = LabProp.getAttribute("id");
            oLabel = new TLabel(id);
            oLabel.Text = Prop.getAttribute("text");
            oLabel.Desc = Prop.getAttribute("desc");
            oLabel.X = LabProp.getAttribute("x");
            oLabel.Y = LabProp.getAttribute("y");
            oLabel.Width = LabProp.getAttribute("width");
            oLabel.Height = LabProp.getAttribute("height");
            oNode.Label = oLabel;
        }
        if (oNode.zIndex == '')
            oNode.zIndex = this.getMinZIndex() - 1;
        this.addStep(oNode);
    }
    this.Modified = false;
    return true;
};
TTopFlow.prototype.SaveToXML = function (id) {
    var xmlDoc = new ActiveXObject('MSXML2.DOMDocument');
    xmlDoc.async = false;
    xmlDoc.loadXML('<?xml version="1.0" encoding="utf-8"?><CommitFlow/>');
    var xmlRoot = xmlDoc.documentElement;
    var xmlNodeGrp, xmlNode, xmlNode2, xmlCommitFlow, xmlJbpm;
    xmlCommitFlow = xmlDoc.createNode(1, "Flow", "");
    xmlRoot.appendChild(xmlCommitFlow);
    xmlJbpm = xmlDoc.createNode(1, "process-definition", "");
    xmlJbpm.setAttribute("name", this.ID);
    xmlJbpm.setAttribute("xmlns", "urn:jbpm.org:jpdl-3.2");
    xmlRoot.appendChild(xmlJbpm);
    xmlCommitFlow.setAttribute("id", this.ID);
    xmlCommitFlow.setAttribute("formid", this.FormID);
    xmlCommitFlow.setAttribute("filename", this.FileName);
    xmlCommitFlow.setAttribute("text", this.Text);
    xmlCommitFlow.setAttribute("password", this.Password);
    xmlCommitFlow.setAttribute("width", this.Width);
    xmlCommitFlow.setAttribute("height", this.Height);
    xmlNodeGrp = xmlDoc.createNode(1, "Procs", "");
    xmlCommitFlow.appendChild(xmlNodeGrp);
    for (var i = 0; i < this.Procs.length; i++) {
        Proc = this.Procs[i];
        xmlNode = xmlDoc.createNode(1, "Proc", "");
        xmlNode2 = xmlDoc.createNode(1, "BaseProperties", "");
        xmlNode2.setAttribute("id", Proc.ID);
        xmlNode2.setAttribute("text", Proc.Text);
        xmlNode2.setAttribute("ProcType", Proc.ProcType);
        xmlNode2.setAttribute("SameCredit", Proc.SameCredit);
        xmlNode2.setAttribute("WarnType", Proc.WarnType);
        xmlNode2.setAttribute("TimeLimit", Proc.TimeLimit);
        xmlNode2.setAttribute("Executer", Proc.Executer);
        xmlNode2.setAttribute("Aidancer", Proc.Aidancer);
        xmlNode2.setAttribute("hExecuter", Proc.hExecuter);
        xmlNode2.setAttribute("hAidancer", Proc.hAidancer);
        xmlNode.appendChild(xmlNode2);
        xmlNode2 = xmlDoc.createNode(1, "VMLProperties", "");
        xmlNode2.setAttribute("shapetype", Proc.ShapeType);
        xmlNode2.setAttribute("width", Proc.Width);
        xmlNode2.setAttribute("height", Proc.Height);
        xmlNode2.setAttribute("x", Proc.X);
        xmlNode2.setAttribute("y", Proc.Y);
        xmlNode2.setAttribute("textWeight", Proc.TextWeight);
        xmlNode2.setAttribute("strokeWeight", Proc.StrokeWeight);
        xmlNode2.setAttribute("zIndex", Proc.zIndex);
        xmlNode.appendChild(xmlNode2);
        xmlNodeGrp.appendChild(xmlNode);
        this.addProcXML(xmlDoc, xmlJbpm, Proc);
    }
    xmlNodeGrp = xmlDoc.createNode(1, "Steps", "");
    xmlCommitFlow.appendChild(xmlNodeGrp);
    for (i = 0; i < this.Steps.length; i++) {
        Step = this.Steps[i];
        xmlNode = xmlDoc.createNode(1, "Step", "");
        xmlNode2 = xmlDoc.createNode(1, "BaseProperties", "");
        xmlNode2.setAttribute("id", Step.ID);
        xmlNode2.setAttribute("text", Step.Text);
        xmlNode2.setAttribute("from", Step.FromProc);
        xmlNode2.setAttribute("to", Step.ToProc);
        xmlNode2.setAttribute("Cond", Step.Cond);
        xmlNode2.setAttribute("Event", Step.Event);
        xmlNode2.setAttribute("Desc", Step.Desc);
        xmlNode.appendChild(xmlNode2);
        xmlNode2 = xmlDoc.createNode(1, "VMLProperties", "");
        xmlNode2.setAttribute("points", Step.Points);
        xmlNode2.setAttribute("fromRelX", Step.fromRelX);
        xmlNode2.setAttribute("fromRelY", Step.fromRelY);
        xmlNode2.setAttribute("toRelX", Step.toRelX);
        xmlNode2.setAttribute("toRelY", Step.toRelY);
        xmlNode2.setAttribute("shapetype", Step.ShapeType);
        xmlNode2.setAttribute("startArrow", Step.StartArrow);
        xmlNode2.setAttribute("endArrow", Step.EndArrow);
        xmlNode2.setAttribute("strokeWeight", Step.StrokeWeight);
        xmlNode2.setAttribute("zIndex", Step.zIndex);
        xmlNode.appendChild(xmlNode2);
        xmlNode2 = xmlDoc.createNode(1, "LabelProperties", "");
        xmlNode2.setAttribute("id", Step.Label.ID);
        xmlNode2.setAttribute("width", Step.Label.Width);
        xmlNode2.setAttribute("height", Step.Label.Height);
        xmlNode2.setAttribute("x", Step.Label.X);
        xmlNode2.setAttribute("y", Step.Label.Y);
        xmlNode.appendChild(xmlNode2);
        xmlNodeGrp.appendChild(xmlNode);
    }
    var xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    xmlHttp.open("POST", "_SaveFlowXML.aspx?processDefId=" + id + "&IsInsert=0", false);
    xmlHttp.setRequestHeader("Content-type", "text/xml");
    xmlHttp.send(xmlDoc.xml);
    S = xmlHttp.responseText.trim();
    this.Modified = (S != "");
    return S;
};
TTopFlow.prototype.getJbpmXml = function () {
    var xmlDoc = new ActiveXObject('MSXML2.DOMDocument');
    xmlDoc.async = false;
    xmlDoc.loadXML('<?xml version="1.0" encoding="utf-8"?><process-definition/>');
    var xmlRoot = xmlDoc.documentElement;
    xmlRoot.setAttribute("name", this.ID);
    xmlRoot.setAttribute("xmlns", "urn:jbpm.org:jpdl-3.2");
    for (var i = 0; i < this.Procs.length; i++) {
        Proc = this.Procs[i];
        this.addProcXML(xmlDoc, xmlRoot, Proc);
    }
    return this.formatXml(xmlDoc.xml);
}
TTopFlow.prototype.formatXml = function (text) {
    text = '\n' + text.replace(/(<\w+)(\s.*?>)/g, function ($0, name, props) {
        return name + ' ' + props.replace(/\s+(\w+=)/g, " $1");
    }
    ).replace(/>\s*?</g, ">\n<");
    text = text.replace(/\n/g, '\r').replace(/<!--(.+?)-->/g, function ($0, text) {
        var ret = '<!--' + escape(text) + '-->';
        return ret;
    }
    ).replace(/\r/g, '\n');
    var rgx = /\n(<(([^\?]).+?)(?:\s|\s*?>|\s*?(\/)>)(?:.*?(?:(?:(\/)>)|(?:<(\/)\2>)))?)/mg;
    var nodeStack = [];
    var commitflow = this;
    var output = text.replace(rgx, function ($0, all, name, isBegin, isCloseFull1, isCloseFull2, isFull1, isFull2) {
        var isClosed = (isCloseFull1 == '/') || (isCloseFull2 == '/') || (isFull1 == '/') || (isFull2 == '/');
        var prefix = '';
        if (isBegin == '!') {
            prefix = commitflow.getPrefix(nodeStack.length);
        }
        else {
            if (isBegin != '/') {
                prefix = commitflow.getPrefix(nodeStack.length);
                if (!isClosed) {
                    nodeStack.push(name);
                }
            }
            else {
                nodeStack.pop();
                prefix = commitflow.getPrefix(nodeStack.length);
            }
        }
        var ret = '\n' + prefix + all;
        return ret;
    }
    );
    var prefixSpace = -1;
    var outputText = output.substring(1);
    outputText = outputText.replace(/\n/g, '\r').replace(/(\s*)<!--(.+?)-->/g, function ($0, prefix, text) {
        if (prefix.charAt(0) == '\r')
            prefix = prefix.substring(1);
        text = unescape(text).replace(/\r/g, '\n');
        var ret = '\n' + prefix + '<!--' + text.replace(/^\s/mg, prefix) + '-->';
        return ret;
    }
    );
    return outputText.replace(/\s+$/g, '').replace(/\r/g, '\r\n');
}
TTopFlow.prototype.getPrefix = function (prefixIndex) {
    var span = ' ';
    var output = [];
    for (var i = 0; i < prefixIndex; ++i) {
        output.push(span);
    }
    return output.join('');
}
var _FLOW = new TTopFlow("");
var _TOOLTYPE = "point";
var _CURRENTX = _CURRENTY = 0;
var _FOCUSTEDOBJ = null;
var _ZOOM = 1;
var _MOVEOBJ = null;
var _MOVETYPE = "";
var _DOLOG = [];
var _DOLOGINDEX = -1;
var _strPt1 = "";
var _strPt2 = "";
var _strSltPt = "";
var _strLine1 = "";
var _strLine2 = "";
var _strSltLine = "";
var _PointOrLine;
var isSelectPoint = 0;
var isSelectLine = 0;
var _clkPx = 0;
var _clkPy = 0;
var ptMoveType = "";
var oOval = null;
var _logMoveType = "";
var _MOVELINEOBJ = null;

function objFocusedOn(objId) {
    objFocusedOff();
    _FOCUSTEDOBJ = document.getElementById(objId);
    if (_FOCUSTEDOBJ != null) {
        _FOCUSTEDOBJ.StrokeColor = _FOCUSTEDOBJ.fsc;
        _FOCUSTEDOBJ.StrokeWeight = 1.2;
    }
    var x = (event.x + document.body.scrollLeft) / _ZOOM;
    var y = (event.y + document.body.scrollTop) / _ZOOM;
    _clkPx = x / 4 * 3 + "pt";
    _clkPy = y / 4 * 3 + "pt";
    if (_FOCUSTEDOBJ.tagName == "PolyLine") {
        modifyStepShape(_FOCUSTEDOBJ, x, y);
    }
    stuffProp();
}
function createOval(x, y) {
    oOval = document.createElement("v:oval");
    oOval.style.position = "absolute";
    oOval.style.width = "6px";
    oOval.style.height = "6px"
    oOval.style.left = x;
    oOval.style.top = y;
    oOval.fillcolor = "red";
    oOval.strokecolor = "red";
    document.body.appendChild(oOval);
}
function getMinMod(c, m) {
    var iMin = 0;
    var k = 0;
    c = Math.round(c);
    for (var i = c - m / 2; i < c + m / 2; i++) {
        if (i % m == 0) {
            if (k == 0) {
                iMin = i;
            }
            else {
                if (Math.abs(i - c) < Math.abs(iMin - c)) {
                    iMin = i;
                }
            }
            k++;
        }
    }
    return iMin;
}
function getNearPt(oProc, x, y) {
    var objProc = document.getElementById(oProc.ID)
    var fromW = parseInt(objProc.style.width);
    var fromH = parseInt(objProc.style.height);
    var fromX = parseInt(objProc.style.left);
    var fromY = parseInt(objProc.style.top);
    var arrX = new Array();
    var arrY = new Array();
    var arrPos = new Array(0, 0.25, 0.5, 0.75, 1);
    var nX, nY, m, n, nearPt, poX, poY;
    arrX[0] = fromX;
    arrX[1] = fromX + fromW / 4;
    arrX[2] = fromX + fromW / 2;
    arrX[3] = fromX + fromW * 3 / 4;
    arrX[4] = fromX + fromW;
    arrY[0] = fromY;
    arrY[1] = fromY + fromH / 4;
    arrY[2] = fromY + fromH / 2;
    arrY[3] = fromY + fromH * 3 / 4;
    arrY[4] = fromY + fromH;
    m = 0;
    n = 0;
    for (var i = 0; i < 4; i++) {
        Math.abs(x - arrX[i]) < Math.abs(x - arrX[i + 1]) ? m = m : m = i + 1;
        Math.abs(y - arrY[i]) < Math.abs(y - arrY[i + 1]) ? n = n : n = i + 1;
    }
    if (m > 0 && m < 4 && n > 0 && n < 4) {
        if (m == 3) {
            m = 4;
        }
        else {
            m = 0;
        }
        if (n == 3) {
            n = 4;
        }
        else {
            n = 0;
        }
    }
    nX = arrX[m];
    nY = arrY[n];
    poX = arrPos[m];
    poY = arrPos[n];
    nearPt = nX * 3 / 4 + "pt," + nY * 3 / 4 + "pt|~|" + poX + "," + poY
    return nearPt;
}
function alertPro(obj) {
    for (var i in obj) {
        alert(i + '\n' + obj[i])
    }
}
function modifyStepShape(objstep, x, y) {
    _MOVEOBJ = document.getElementById(objstep.id);
    _MOVELINEOBJ = new TStep(_FLOW);
    _MOVELINEOBJ.clone(_FLOW.getStepByID(objstep.id));
    _MOVEOBJ = _FLOW.getStepByID(objstep.id);
    if (_MOVEOBJ.Label) {
        document.getElementById(_MOVEOBJ.Label.ID).style.backgroundColor = '#dddddd';
    }
    var strPt = _MOVEOBJ.Points;
    var aryPt = strPt.split(',');
    var nPt = aryPt.length - 1;
    _strPt2 = "";
    _strPt1 = "";
    _strLine2 = "";
    _strLine1 = "";
    for (i = 0; i <= nPt; i = i + 2) {
        var m = aryPt[i].substr(0, aryPt[i].length - 2) * 4 / 3;
        var n = aryPt[i + 1].substr(0, aryPt[i + 1].length - 2) * 4 / 3;
        var sqrta = Math.sqrt((x - m) * (x - m) + (y - n) * (y - n));
        if (isSelectPoint == 0 && sqrta <= 10) {
            _PointOrLine = 0;
            isSelectPoint = 1;
            _MOVETYPE = "line_m";
            _strSltPt = aryPt[i] + ',' + aryPt[i + 1];
            _clkPx = aryPt[i];
            _clkPy = aryPt[i + 1];
            if (i == 0) {
                ptMoveType = "from";
            }
            if (i == nPt - 1) {
                ptMoveType = "to";
            }
        }
        else {
            if (isSelectPoint == 1) {
                _strPt2 = _strPt2 + ',' + aryPt[i] + ',' + aryPt[i + 1];
            }
            else {
                _strPt1 = _strPt1 + ',' + aryPt[i] + ',' + aryPt[i + 1];
            }
        }
        if (i <= nPt - 3) {
            var r = aryPt[i + 2].substr(0, aryPt[i + 2].length - 2) * 4 / 3;
            var s = aryPt[i + 3].substr(0, aryPt[i + 3].length - 2) * 4 / 3;
            if ((Math.abs(x * (n - s) + y * (r - m) + (m * s - n * r)) / Math.sqrt((n - s) * (n - s) + (r - m) * (r - m)) <= 5) && (isSelectLine == 0) && sqrta > 10 && isSelectPoint == 0) {
                _PointOrLine = 1;
                _MOVETYPE = "line_m";
                isSelectLine = 1;
                _strSltLine = aryPt[i] + ',' + aryPt[i + 1] + ',' + aryPt[i + 2] + ',' + aryPt[i + 3];
                _clkPx = x / 4 * 3 + "pt";
                _clkPy = y / 4 * 3 + "pt";
            }
            else {
                if (isSelectLine == 1) {
                    if (i <= nPt - 3) {
                        _strLine2 = _strLine2 + ',' + aryPt[i + 2] + ',' + aryPt[i + 3];
                    }
                }
                else {
                    _strLine1 = _strLine1 + "," + aryPt[i] + ',' + aryPt[i + 1];
                }
            }
        }
    }
    if (_strPt1 != '') {
        _strPt1 = _strPt1.substr(1) + ',';
    }
    if (_strLine1 != '') {
        _strLine1 = _strLine1.substr(1) + ",";
    }
}
function objFocusedOff() {
    if (_FOCUSTEDOBJ != null) {
        _FOCUSTEDOBJ.StrokeColor = _FOCUSTEDOBJ.sc;
        _FOCUSTEDOBJ.StrokeWeight = 1;
        var oLabel = document.getElementById('lab' + _FOCUSTEDOBJ.id);
        if (oLabel) {
            oLabel.style.backgroundColor = '';
        }
    }
    _FOCUSTEDOBJ = null;
    isSelectPoint = 0;
    isSelectLine = 0;
    ptMoveType = "";
    oOval = null;
    return;
}
function deleteObj(ObjId) {
    var obj = document.getElementById(ObjId);
    if (obj == null) {
        return false;
    }
    if (obj.typ != "Proc" && obj.typ != "Step") {
        return false;
    }
    if (obj.typ == "Proc" && (obj.st == "begin" || obj.st == "end" || obj.st == "first")) {
        alert("不能删除!一个流程图中，[开始节点],[第一个节点],[结束结点]是必需的");
        return false;
    }
    var objVML = obj.typ == "Proc" ? _FLOW.getProcByID(_FOCUSTEDOBJ.id) : _FLOW.getStepByID(_FOCUSTEDOBJ.id);
    if (obj.typ == "Step" && objVML.FromProc == 'begin') {
        alert('不能删除开始节点联线!');
        return false;
    }
    if (confirm("确定要删除[" + objVML.Text + "]吗?")) {
        objFocusedOff();
        if (obj.typ == "Proc") {
            var Proc = _FLOW.getProcByID(ObjId);
            _FLOW.deleteProcByID(ObjId);
            pushLog("delproc", Proc);
        }
        else {
            var Step = _FLOW.getStepByID(ObjId);
            _FLOW.deleteStepByID(ObjId);
            pushLog("delstep", Step);
        }
        _FLOW.Modified = true;
        DrawAll();
    }
}
function changeProcID(OldID, NewID) {
    var Step;
    for (var i = 0; i < _FLOW.Steps.length; i++) {
        Step = _FLOW.Steps[i];
        if (Step.FromProc == OldID) {
            Step.FromProc = NewID;
        }
        if (Step.ToProc == OldID) {
            Step.ToProc = NewID;
        }
    }
}
function saveStepsToProc(obj) {
    for (var i = 0; i < _FLOW.Steps.length; i++) {
        var oStep = _FLOW.Steps[i];
        if (oStep.FromProc == obj.id || oStep.ToProc == obj.id) {
        }
    }
}
function changeProcPos(obj) {
    for (var i = 0; i < _FLOW.Steps.length; i++) {
        Step = _FLOW.Steps[i];
        if (Step.FromProc == obj.id || Step.ToProc == obj.id) {
            objStepHTML = document.getElementById(Step.ID);
            if (Step.ShapeType == "Line") {
                Step.getPath();
                objStepHTML.from = Step.FromPoint;
                objStepHTML.to = Step.ToPoint;
            }
            else if (Step.ShapeType == "PolyLine") {
                var strPt = "";
                var arrPt = Step.Points.split(",");
                var objWidth = obj.style.width;
                var objHeight = obj.style.height;
                var objX = obj.style.left;
                var objY = obj.style.top;
                var strMoveType = _MOVETYPE;
                objWidth = objWidth.substr(0, objWidth.length - 2);
                objHeight = objHeight.substr(0, objHeight.length - 2);
                objX = objX.substr(0, objX.length - 2) * 1;
                objY = objY.substr(0, objY.length - 2) * 1;
                if (_MOVETYPE == "") {
                    strMoveType = _logMoveType;
                }
                if (Step.FromProc == obj.id) {
                    strPt = (objX + objWidth * Step.fromRelX) * 3 / 4 + "pt," + (objY + objHeight * Step.fromRelY) * 3 / 4 + "pt"
                    for (var j = 2; j < arrPt.length; j++) {
                        strPt = strPt + "," + arrPt[j]
                    }
                }
                if (Step.ToProc == obj.id) {
                    for (var j = 0; j < arrPt.length - 2; j++) {
                        strPt = strPt + arrPt[j] + ","
                    }
                    strPt = strPt + (objX + objWidth * Step.toRelX) * 3 / 4 + "pt," + (objY + objHeight * Step.toRelY) * 3 / 4 + "pt"
                }
                Step.Points = strPt;
                objStepHTML.outerHTML = Step.toStringWithoutLabel();
            }
        }
    }
    _logMoveType = "";
}
function editProc(objId) {
}
function editStep(objId) {
    var oldobj = new TStep(_FLOW), newobj = new TStep(_FLOW);
    var step = _FLOW.getStepByID(objId);
    oldobj.clone(step);
    var x = (event.x + document.body.scrollLeft) / _ZOOM;
    var y = (event.y + document.body.scrollTop) / _ZOOM;
    var strPt = step.Points;
    var aryPt = strPt.split(',');
    var nPt = aryPt.length - 1;
    isSelectPoint = 0;
    _strPt2 = "";
    _strPt1 = "";
    for (i = 0; i <= nPt; i = i + 2) {
        var m = aryPt[i].substr(0, aryPt[i].length - 2) * 1.333;
        var n = aryPt[i + 1].substr(0, aryPt[i + 1].length - 2) * 1.333;
        var sqrta = Math.sqrt((x - m) * (x - m) + (y - n) * (y - n));
        if (isSelectPoint == 0 && sqrta <= 10) {
            _strSltPt = aryPt[i] + ',' + aryPt[i + 1];
        }
        else if (isSelectPoint == 1) {
            _strPt2 = _strPt2 + ',' + aryPt[i] + ',' + aryPt[i + 1];
        }
        else {
            _strPt1 = _strPt1 + ',' + aryPt[i] + ',' + aryPt[i + 1];
        }
    }
    if (_strPt1 != '') {
        _strPt1 = _strPt1.substr(1);
    }
    step.Points = _strPt1 + _strPt2;
    document.getElementById(step.ID).outerHTML = step.toStringWithoutLabel();
    objFocusedOn(objId);
    _FLOW.Modified = true;
}
function beforePropChange(oItem) {
    if ("rule" in oItem) {
        r = new RegExp(oItem.rule);
        if (!r.test(oItem.value)) {
            alert(oItem.msg);
            oItem.focus();
            if (oItem.tagName.toLowerCase() == "input") {
                oItem.select();
            }
            return false;
        }
    }
    return true;
}
function setPropID(oItem) {
    var obj = null, obj2 = null;
    obj = _FOCUSTEDOBJ.typ == "Proc" ? _FLOW.getProcByID(_FOCUSTEDOBJ.id) : _FLOW.getStepByID(_FOCUSTEDOBJ.id);
    var oldID = obj.ID;
    if (oldID == oItem.value) {
        return;
    }
    obj2 = _FLOW.getProcByID(oItem.value);
    if (obj2 == null) {
        obj2 = _FLOW.getStepByID(oItem.value);
    }
    if (obj2 != null) {
        alert("名称[" + oItem.value + "-" + obj2.Text + "]已经存在!请重新输入!");
        oItem.focus();
        oItem.select();
        return;
    }
    document.all(_FOCUSTEDOBJ.id + "Text").id = oItem.value + "Text";
    obj.ID = oItem.value;
    _FOCUSTEDOBJ.id = oItem.value;
    if (_FOCUSTEDOBJ.typ == "Proc") {
        changeProcID(oldID, obj.ID);
    }
    pushLog("editprop",
    {
        "obj": obj, "prop": "ID", "_old": oldID, "_new": obj.ID
    }
    );
}
function setPropText(oItem) {
    var obj = _FOCUSTEDOBJ.typ == "Proc" ? _FLOW.getProcByID(_FOCUSTEDOBJ.id) : _FLOW.getStepByID(_FOCUSTEDOBJ.id);
    if (obj.Text == oItem.value) {
        return;
    }
    var oldValue = obj.Text;
    obj.Text = oItem.value;
    if (obj.ObjType == "Proc") {
        DrawAll();
    }
    else {
        document.getElementById('lab' + _FOCUSTEDOBJ.id).innerHTML = oItem.value;
    }
    objFocusedOn(obj.ID);
    pushLog("editprop",
    {
        "obj": obj, "prop": "Text", "_old": oldValue, "_new": obj.Text
    }
    );
}
function setPropCond(oItem) {
    var obj = _FLOW.getStepByID(_FOCUSTEDOBJ.id);
    if (obj.Cond == oItem.value) {
        return;
    }
    var oldValue = obj.Cond;
    obj.Cond = oItem.value;
    document.all(_FOCUSTEDOBJ.id + "Text").innerHTML = oItem.value;
    pushLog("editprop",
    {
        "obj": obj, "prop": "Cond", "_old": oldValue, "_new": obj.Cond
    }
    );
}
function setProcType(oItem) {
    var obj = _FLOW.getProcByID(_FOCUSTEDOBJ.id);
    if (obj.ProcType == oItem.value) {
        return;
    }
    var oldValue = obj.ProcType;
    var oldShape = obj.ShapeType;
    obj.ProcType = oItem.value;
    var strImageType = '';
    var idPerfix = 'p';
    var idPostfix = '';
    switch (oItem.value) {
        case 'andsign': case 'unandsign': case 'connectsign': strImageType = 'roundrect';
            idPerfix = 'p';
            break;
        case 'fork': strImageType = 'diamond';
            idPerfix = 'f';
            break;
        case 'andjoin': case 'unandjoin': strImageType = 'rect';
            idPerfix = 'j';
            break;
        default: break;
    }
    obj.ShapeType = strImageType;
    var newId = _FLOW.getProcNewId(idPerfix, obj);
    newId = newId;
    for (i = _FLOW.Steps.length - 1; i >= 0; i--) {
        if (_FLOW.Steps[i].FromProc == obj.ID) {
            _FLOW.Steps[i].FromProc = newId;
        }
        if (_FLOW.Steps[i].ToProc == obj.ID) {
            _FLOW.Steps[i].ToProc = newId;
        }
    }
    obj.ID = newId;
    DrawAll();
    objFocusedOn(obj.ID);
    pushLog("editprop",
    {
        "obj": obj, "prop": "ProcType", "_old": oldValue, "_new": obj.ProcType, "_oldShape": oldShape, "_newShape": obj.ShapeType
    }
    );
}
function setSelectExit(oItem) {
    var obj = _FLOW.getProcByID(_FOCUSTEDOBJ.id);
    var oldValue = obj.SelectExit;
    var newValue = 0;
    if (oItem.checked) {
        newValue = 1;
    }
    obj.SelectExit = newValue;
    pushLog("editprop",
    {
        "obj": obj, "prop": "SelectExit", "_old": oldValue, "_new": obj.newValue
    }
    );
}
function setSameCredit(oItem) {
    var obj = _FLOW.getProcByID(_FOCUSTEDOBJ.id);
    var oldValue = obj.SameCredit;
    var newValue = 0;
    if (oItem.checked) {
        newValue = 1;
    }
    obj.SameCredit = newValue;
    pushLog("editprop",
    {
        "obj": obj, "prop": "SameCredit", "_old": oldValue, "_new": obj.newValue
    }
    );
}
function setTimeLimit(oItem) {
    var obj = _FLOW.getProcByID(_FOCUSTEDOBJ.id);
    var oldValue = obj.TimeLimit;
    if (obj.TimeLimit == oItem.value) {
        return;
    }
    obj.TimeLimit = oItem.value;
    pushLog("editprop",
    {
        "obj": obj, "prop": "TimeLimit", "_old": oldValue, "_new": obj.TimeLimit
    }
    );
}
function setWarnType() {
    var obj = _FLOW.getProcByID(_FOCUSTEDOBJ.id);
    var oldValue = obj.WarnType;
    var isNote = document.getElementById('note').checked;
    var isSMS = document.getElementById('sms').checked;
    var isEmail = document.getElementById('email').checked;
    var strWarnType = ',';
    if (isNote) {
        strWarnType += 'note';
    }
    if (isSMS) {
        strWarnType += 'sms';
    }
    if (isEmail) {
        strWarnType += 'email';
    }
    strWarnType.replace(',', '');
    obj.WarnType = strWarnType;
    pushLog("editprop",
    {
        "obj": obj, "prop": "WarnType", "_old": oldValue, "_new": obj.WarnType
    }
    );
}
function setExecuter(oItem) {
    var obj = _FLOW.getProcByID(_FOCUSTEDOBJ.id);
    var oldValue = obj.Executer;
    var oldValue2 = obj.hExecuter;
    oItem = document.getElementById('actor');
    if (obj.Executer == oItem.value) {
        return;
    }
    obj.Executer = oItem.value;
    obj.hExecuter = document.getElementById('hactor').value;
    pushLog("editprop",
    {
        "obj": obj, "prop": "Executer", "_old": oldValue, "_new": obj.Executer, "_old2": oldValue2, "_new2": obj.hExecuter
    }
    );
}
function setAidancer(oItem) {
    var obj = _FLOW.getProcByID(_FOCUSTEDOBJ.id);
    var oldValue = obj.Aidancer;
    var oldValue2 = obj.hAidancer;
    oItem = document.getElementById('reader');
    if (obj.Aidancer == oItem.value) {
        return;
    }
    obj.Aidancer = oItem.value;
    obj.hAidancer = document.getElementById('hreader').value;
    pushLog("editprop",
    {
        "obj": obj, "prop": "Aidancer", "_old": oldValue, "_new": obj.Aidancer, "_old2": oldValue2, "_new2": obj.hAidancer
    }
    );
}
function setEvent(oItem) {
    var obj = _FLOW.getStepByID(_FOCUSTEDOBJ.id);
    var oldValue = obj.Event;
    if (obj.Event == oItem.value) {
        return;
    }
    obj.Event = oItem.value;
    pushLog("editprop",
    {
        "obj": obj, "prop": "Event", "_old": oldValue, "_new": obj.Event
    }
    );
}
function setCond(oItem) {
    var obj = _FLOW.getStepByID(_FOCUSTEDOBJ.id);
    var oldValue = obj.Cond;
    if (obj.Cond == oItem.value) {
        return;
    }
    obj.Cond = oItem.value;
    pushLog("editprop",
    {
        "obj": obj, "prop": "Cond", "_old": oldValue, "_new": obj.Cond
    }
    );
}
function setDesc(oItem) {
    var obj = _FLOW.getStepByID(_FOCUSTEDOBJ.id);
    var oldValue = obj.Desc;
    if (obj.Desc == oItem.value) {
        return;
    }
    obj.Desc = oItem.value;
    pushLog("editprop",
    {
        "obj": obj, "prop": "Desc", "_old": oldValue, "_new": obj.Desc
    }
    );
}
function setAspect(val) {
    var obj = _FLOW.getProcByID(_FOCUSTEDOBJ.id);
    var strRadioVal = '';
    if (Math.abs(obj.Width.replace('px', '')) < Math.abs(obj.Height.replace('px', ''))) {
        strRadioVal = 'v';
    }
    else {
        strRadioVal = 'h';
    }
    if (val == strRadioVal) {
        return;
    }
    var w = obj.Width;
    var h = obj.Height;
    var oldVal =
    {
        "X": obj.X, "Y": obj.Y, "Width": w, "Height": h
    };
    var d = (Math.abs(h.replace('px', '')) - Math.abs(w.replace('px', ''))) / 2;
    obj.Width = h;
    obj.Height = w;
    obj.X = Math.abs(obj.X.replace('px', '')) - d + 'px';
    obj.Y = Math.abs(obj.Y.replace('px', '')) + d + 'px';
    DrawAll();
    objFocusedOn(obj.ID);
    changeProcPos(_FOCUSTEDOBJ);
    pushLog("moveproc",
    {
        "objID": obj.ID, "moveType": "proc_nw", "_old": oldVal, "_new":
        {
            "X": obj.X, "Y": obj.Y, "Width": obj.Width, "Height": obj.Height
        }
    }
    );
}
//装载属性窗口
function stuffProp() {
    for (var i = propview.rows.length - 1; i > 0; i--) {
        propview.deleteRow(i);
    }
    if (_FOCUSTEDOBJ == null) {
        return;
    }
    var disableControl = '';
    if (_FLOW.opType != '') {
        disableControl = 'disabled';
    }

    var obj = _FOCUSTEDOBJ.typ == "Proc" ? _FLOW.getProcByID(_FOCUSTEDOBJ.id) : _FLOW.getStepByID(_FOCUSTEDOBJ.id);

    var idTR, idTD, oSelect, oOption;

    idTR = propview.insertRow();
    idTR.height = "25";
    idTR.className = "tabletd";
    idTD = idTR.insertCell();
    idTD.noWrap = true;
    idTD.style.width = "79";
    idTD.align = "center";
    idTD.innerHTML = "编号";
    idTD = idTR.insertCell();
    idTD.innerHTML = '<input disabled="true"  type="text" rule="" msg="" onblur="if(beforePropChange(this)) setPropID(this);" name="pID" maxlength="10" value="' + obj.ID + '" style="width:95%;">';
    //Text
    idTR = propview.insertRow();
    idTR.height = "25";
    idTR.className = "tabletd";
    idTD = idTR.insertCell();
    idTD.noWrap = true;
    idTD.style.width = "79";
    idTD.align = "center";
    idTD.innerHTML = "名称";
    idTD = idTR.insertCell();
    idTD.innerHTML = '<input id="pName" type="text" maxlength="20" rule="^\\S+$" msg="[名称]不能为空或包含空字符!" onblur="if(beforePropChange(this)) setPropText(this);" name="pText" maxlength="10" value="' + obj.Text + '" style="width:95%;">'

    // 判断是否是流程
    if (_FOCUSTEDOBJ.typ == "Proc") {
        //节点类型
        idTR = propview.insertRow();
        idTR.height = "25";
        idTR.className = "tabletd";
        idTD = idTR.insertCell();
        idTD.noWrap = true;
        idTD.style.width = "79";
        idTD.align = "center";
        idTD.innerHTML = "类型";
        idTD = idTR.insertCell();

        idTD.innerHTML = '<select name="pShapeType" ' + disableControl + ' onchange="setProcType(this);" style="width:95%;"></select>';
        oSelect = document.getElementById("pShapeType");
        createProcTypeOption(obj.ProcType, oSelect);

        //如果是开始或者结束或是第一个流程便不能改变流程类型
        if (obj.ProcType == 'begin' || obj.ProcType == 'end' || obj.ProcType == 'first') {
            oSelect.disabled = true;
        }

        oSelect.value = obj.ProcType;

        if (obj.ProcType == 'andjoin' || obj.PorcType == 'unandjoin') {
            idTR = propview.insertRow();
            idTR.height = "22";
            idTD = idTR.insertCell();
            idTD.noWrap = true;
            idTD.align = 'right';
            idTD.innerHTML = "&nbsp;";
            idTD = idTR.insertCell();
            idTD.innerHTML = '<input type="radio" ' + disableControl + ' name="forkAspect" value="v" onclick="setAspect(this.value);">纵向<input type="radio" onclick="setAspect(this.value);" value="h" name="forkAspect">横向';
            var strRadioVal = '';
            if (Math.abs(obj.Width.replace('px', '')) < Math.abs(obj.Height.replace('px', ''))) {
                strRadioVal = 'v';
            }
            else {
                strRadioVal = 'h';
            }
            var radios = document.getElementsByName('forkAspect');

            for (var i = 0; i < radios.length; i++) {
                if (radios[i].value == strRadioVal) {
                    radios[i].checked = true;
                }
            }
        }
        if (obj.ProcType == 'andsign' || obj.ProcType == 'unandsign' || obj.ProcType == 'connectsign' || obj.ProcType == 'first') {
            if (obj.ProcType != 'first') {
            }
        }
    }
    else {
    }
}
function createProcTypeOption(ptype, oSelect) {
    switch (ptype) {
        case 'begin':
            oOption = document.createElement("OPTION");
            oSelect.options.add(oOption);
            oOption.innerText = "开始";
            oOption.value = "begin";
            break;

        case 'end':
            oOption = document.createElement("OPTION");
            oSelect.options.add(oOption);
            oOption.innerText = "结束";
            oOption.value = "end";
            break;

        case 'first':
            oOption = document.createElement("OPTION");
            oSelect.options.add(oOption);
            oOption.innerText = "第一个节点";
            oOption.value = "first";
            break;

        case 'andsign':
        case 'unandsign':
        case 'connectsign':
        case 'fork':
        case 'andjoin':
        case 'unandjoin':
        default: oOption = document.createElement("OPTION");

            oSelect.options.add(oOption);
            oOption.innerText = "会签";
            oOption.value = "andsign";
            oOption = document.createElement("OPTION");
            oSelect.options.add(oOption);
            oOption.innerText = "非会签";
            oOption.value = "unandsign";
            oOption = document.createElement("OPTION");
            oSelect.options.add(oOption);
            oOption.innerText = "串签";
            oOption.value = "connectsign";
            oOption = document.createElement("OPTION");
            oSelect.options.add(oOption);
            oOption.innerText = "分支节点";
            oOption.value = "fork";
            oOption = document.createElement("OPTION");
            oSelect.options.add(oOption);
            oOption.innerText = "并流会聚";
            oOption.value = "andjoin";
            oOption = document.createElement("OPTION");
            oSelect.options.add(oOption);
            oOption.innerText = "非并流会聚";
            oOption.value = "unandjoin";
            break;
    }
}

function emptyLog() {
    _DOLOG = [];
    _DOLOGINDEX = -1;
}
function pushLog(act, obj) {
    var newLog = _DOLOG.slice(0, _DOLOGINDEX + 1);
    _DOLOG = newLog;
    _DOLOGINDEX = _DOLOG.push(
    {
        "act": act, "val": obj
    }
    ) - 1;
}
function getLog() {
    return _DOLOG[_DOLOGINDEX];
}
function undoLog() {
    if (_DOLOGINDEX == -1) {
        alert("没有操作记录可以撤消.");
        return;
    }
    if (doLog("undo")) {
        _DOLOGINDEX--;
    }
}
function redoLog() {
    if (_DOLOGINDEX == _DOLOG.length - 1) {
        alert("没有操作记录可以恢复.");
        return;
    }
    _DOLOGINDEX++;
    doLog("redo");
}
function doLog(act) {
    var log = getLog();
    switch (log.act) {
        case "addproc": act == "undo" ? _FLOW.deleteProcByID(log.val.ID) : _FLOW.addProc(log.val);
            DrawAll();
            break;
        case "addstep": act == "undo" ? _FLOW.deleteStepByID(log.val.ID) : _FLOW.addStep(log.val);
            DrawAll();
            break;
        case "delproc": act == "undo" ? _FLOW.addProc(log.val) : _FLOW.deleteProcByID(log.val.ID);
            DrawAll();
            break;
        case "delstep": act == "undo" ? _FLOW.addStep(log.val) : _FLOW.deleteStepByID(log.val.ID);
            DrawAll();
            break;
        case "editproc": if (act == "undo") {
                var Proc = _FLOW.getProcByID(log.val._new.ID);
                Proc.clone(log.val._old);
                if (log.val._new.ID != log.val._old.ID) {
                    changeProcID(log.val._new.ID, log.val._old.ID);
                }
            }
            else {
                var Proc = _FLOW.getProcByID(log.val._old.ID);
                Proc.clone(log.val._new);
                if (log.val._new.ID != log.val._old.ID) {
                    changeProcID(log.val._old.ID, log.val._new.ID);
                }
            }
            DrawAll();
            objFocusedOn(act == "undo" ? log.val._old.ID : log.val._new.ID);
            break;
        case "editstep": if (act == "undo") {
                var Step = _FLOW.getStepByID(log.val._new.ID);
                Step.clone(log.val._old);
            }
            else {
                var Step = _FLOW.getStepByID(log.val._old.ID);
                Step.clone(log.val._new);
            }
            DrawVML();
            objFocusedOn(act == "undo" ? log.val._old.ID : log.val._new.ID);
            break;
        case "moveproc": var obj = _FLOW.getProcByID(log.val.objID);
            if (act == "undo") {
                obj.setPropValue("X", log.val._old.X);
                obj.setPropValue("Y", log.val._old.Y);
                obj.setPropValue("Width", log.val._old.Width);
                obj.setPropValue("Height", log.val._old.Height);
            }
            else {
                obj.setPropValue("X", log.val._new.X);
                obj.setPropValue("Y", log.val._new.Y);
                obj.setPropValue("Width", log.val._new.Width);
                obj.setPropValue("Height", log.val._new.Height);
            }
            changeProcPos(obj.InnerObject);
            DrawAll();
            break;
        case "editprop": var CurrentProp = (act == "undo" ? log.val._old : log.val._new);
            log.val.obj[log.val.prop] = CurrentProp;
            switch (log.val.prop) {
                case "ID": if (log.val.obj.ObjType == "Proc") {
                        act == "undo" ? changeProcID(log.val._new, log.val._old) : changeProcID(log.val._old, log.val._new);
                    }
                    DrawVML();
                    objFocusedOn(log.val.obj.ID);
                    break;
                case "Executer": var _Executer = (act == "undo" ? log.val._old2 : log.val._new2);
                    log.val.obj.hExecuter = _Executer;
                    objFocusedOn(log.val.obj.ID);
                    break;
                case "Aidancer": var _Aidancer = (act == "undo" ? log.val._old2 : log.val._new2);
                    log.val.obj.hAidancer = _Aidancer;
                    objFocusedOn(log.val.obj.ID);
                    break;
                case "Text": DrawAll();
                    objFocusedOn(log.val.obj.ID);
                    break;
                case "ProcType": var _shapeType = (act == "undo" ? log.val._oldShape : log.val._newShape);
                    log.val.obj.ShapeType = _shapeType;
                    DrawVML();
                    objFocusedOn(log.val.obj.ID);
                    break;
                case "TextWeight": document.all(log.val.obj.ID + "Text").style.fontSize = CurrentProp;
                    break;
                case "zIndex": log.val.obj.InnerObject.style.zIndex = CurrentProp;
                    break;
                case "StrokeWeight": log.val.obj.InnerObject.strokeweight = CurrentProp;
                    break;
                case "X": log.val.obj.InnerObject.style.left = CurrentProp;
                    changeProcPos(log.val.obj.InnerObject);
                    break;
                case "Y": log.val.obj.InnerObject.style.top = CurrentProp;
                    changeProcPos(log.val.obj.InnerObject);
                    break;
                case "Width": log.val.obj.InnerObject.style.width = CurrentProp;
                    changeProcPos(log.val.obj.InnerObject);
                    break;
                case "Height": log.val.obj.InnerObject.style.height = CurrentProp;
                    changeProcPos(log.val.obj.InnerObject);
                    break;
                case "Cond": break;
                case "StartArrow": document.all(log.val.obj.ID + "Arrow").startarrow = CurrentProp;
                    break;
                case "EndArrow": document.all(log.val.obj.ID + "Arrow").endarrow = CurrentProp;
                    break;
                case "FromProc": case "ToProc": if (log.val.obj.ShapeType == "Line") {
                        log.val.obj.getPath();
                        log.val.obj.InnerObject.from = log.val.obj.FromPoint;
                        log.val.obj.InnerObject.to = log.val.obj.ToPoint;
                    }
                    else if (log.val.ShapeType == "PolyLine") {
                        log.val.obj.InnerObject.points.value = log.val.obj.getPath();
                    }
                    DrawDataView();
                    break;
            }
            break;
    }
    stuffProp();
    return true;
}
function doProcMouseDown(obj, x, y) {
    if (_TOOLTYPE == "line" || _TOOLTYPE == "polyline") {
        _CURRENTX = x;
        _CURRENTY = y;
        _MOVEOBJ = document.all("_lineui");
        _MOVEOBJ.from = _CURRENTX + "," + (_CURRENTY - 0);
        _MOVEOBJ.to = _MOVEOBJ.from;
        _MOVEOBJ.style.display = "block";
        _MOVETYPE = _TOOLTYPE;
    }
    else {
        var rightSide = (parseInt(obj.style.left) + parseInt(obj.style.width) - x <= 2);
        var bottomSide = (parseInt(obj.style.top) + parseInt(obj.style.height) - y <= 2);
        if (rightSide && bottomSide) {
            _MOVETYPE = "proc_nw";
        }
        else if (rightSide) {
            _MOVETYPE = "proc_e";
        }
        else if (bottomSide) {
            _MOVETYPE = "proc_n";
        }
        else {
            _MOVETYPE = "proc_m";
            _CURRENTX = x - obj.offsetLeft;
            _CURRENTY = y - obj.offsetTop;
        }
        _MOVEOBJ = obj;
    }
    window.event.cancelBubble = true;
}
function fireProcMouseDown(x, y) {
    var curProc = null;
    for (var i = 0; i < _FLOW.Procs.length; i++) {
        Proc = _FLOW.Procs[i];
        if (x >= parseInt(Proc.X) && x <= (parseInt(Proc.X) + parseInt(Proc.Width)) && y >= parseInt(Proc.Y) && y <= (parseInt(Proc.Y) + parseInt(Proc.Height))) {
            curProc = Proc;
        }
    }
    for (var i = 0; i < _FLOW.Steps.length; i++) {
        Proc = _FLOW.Steps[i].Label;
        if (x >= parseInt(Proc.X) && x <= (parseInt(Proc.X) + parseInt(Proc.Width)) && y >= parseInt(Proc.Y) && y <= (parseInt(Proc.Y) + parseInt(Proc.Height))) {
            curProc = Proc;
        }
    }
    if (curProc != null) {
        obj = document.getElementById(curProc.ID);
        if (obj.tagName != 'DIV') {
            objFocusedOn(obj.id);
        }
        doProcMouseDown(obj, x, y);
        return true;
    }
    return false;
}
function doProcMouseMove(obj, x, y) {
    if (_TOOLTYPE == "line" || _TOOLTYPE == "polyline") {
        document.all.Canvas.style.cursor = "crosshair";
    }
    else {
        var rightSide = (parseInt(obj.style.left) + parseInt(obj.style.width) - x <= 2);
        var bottomSide = (parseInt(obj.style.top) + parseInt(obj.style.height) - y <= 2);
        if (rightSide && bottomSide) {
            document.all.Canvas.style.cursor = "NW-resize";
        }
        else if (rightSide) {
            document.all.Canvas.style.cursor = "E-resize";
        }
        else if (bottomSide) {
            document.all.Canvas.style.cursor = "N-resize";
        }
        else {
            document.all.Canvas.style.cursor = "hand";
        }
    }
}
function fireProcMouseMove(x, y) {
    if (document.all.Canvas == null) {
        return;
    }
    for (var i = 0; i < _FLOW.Procs.length; i++) {
        Proc = _FLOW.Procs[i];
        obj = document.getElementById(Proc.ID);
        if (x >= parseInt(Proc.X) && x <= (parseInt(Proc.X) + parseInt(Proc.Width)) && y >= parseInt(Proc.Y) && y <= (parseInt(Proc.Y) + parseInt(Proc.Height))) {
            doProcMouseMove(obj, x, y);
            return true;
        }
    }
    for (var i = 0; i < _FLOW.Steps.length; i++) {
        Proc = _FLOW.Steps[i].Label;
        obj = document.getElementById(Proc.ID);
        if (x >= parseInt(Proc.X) && x <= (parseInt(Proc.X) + parseInt(Proc.Width)) && y >= parseInt(Proc.Y) && y <= (parseInt(Proc.Y) + parseInt(Proc.Height))) {
            doProcMouseMove(obj, x, y);
            return true;
        }
    }
    if (i >= _FLOW.Procs.length) {
        document.all.Canvas.style.cursor = (_TOOLTYPE == "point" ? "default" : "crosshair");
    }
    if (i >= _FLOW.Labels.length) {
        document.all.Canvas.style.cursor = (_TOOLTYPE == "point" ? "default" : "crosshair");
    }
    return false;
}
function doDocMouseDown() {
    if (event.button == 2) {
        return false;
    }
    var x = (event.x + document.body.scrollLeft) / _ZOOM;
    var y = (event.y + document.body.scrollTop) / _ZOOM;
    var oEvt = event.srcElement;
    if (oEvt.id == "tableContainer" || oEvt.id == "") {
        return;
    }
    if (oEvt.typ == "Step") {
        document.all.Canvas.style.cursor = "default";
        return;
    }
    if (fireProcMouseDown(x, y)) {
        return;
    }
    switch (_TOOLTYPE) {
        case "rect": case "roundrect": case "diamond": case "oval": case "fillrect": if (oEvt.tagName != "DIV") {
                return;
            }
            if (oEvt.id != "Canvas") {
                return;
            }
            var obj = document.all("_" + _TOOLTYPE + "ui");
            _CURRENTX = x;
            _CURRENTY = y;
            obj.style.left = _CURRENTX;
            obj.style.top = _CURRENTY;
            obj.style.width = 0;
            obj.style.height = 0;
            obj.style.display = "block"
            _MOVETYPE = _TOOLTYPE;
            break;
    }
}
function doDocMouseMove() {
    var x = (event.x + document.body.scrollLeft) / _ZOOM;
    var y = (event.y + document.body.scrollTop) / _ZOOM;
    var m, n, aryPt, _movePt, sqrta, _moveLine
    switch (_MOVETYPE) {
        case "line": case "polyline": _MOVEOBJ.to = x + "," + (y - 0);
            break;
        case "line_m": var zx = x * _ZOOM
            var zy = y * _ZOOM
            if (oOval == null) {
                createOval(x * _ZOOM, y * _ZOOM);
                if (_PointOrLine == 0) {
                    oOval.fillcolor = "blue";
                    oOval.strokecolor = "blue";
                }
            }
            m = _clkPx.substr(0, _clkPx.length - 2) * 4 / 3;
            n = _clkPy.substr(0, _clkPy.length - 2) * 4 / 3;
            sqrta = Math.sqrt((x - m) * (x - m) + (y - n) * (y - n));
            var _arySltLine = _strSltLine.split(',');
            if (sqrta > 10) {
                if (oOval) {
                    oOval.style.left = zx - 3;
                    oOval.style.top = zy - 3;
                }
                if (_PointOrLine == 0) {
                    _movePt = (x * 3 / 4) + 'pt,' + (y * 3 / 4) + "pt";
                    _MOVEOBJ.Points = _strPt1 + "" + _movePt + "" + _strPt2;
                }
                else {
                    _moveLine = _arySltLine[0] + ',' + _arySltLine[1] + ',' + x * 3 / 4 + 'pt,' + y * 3 / 4 + 'pt,' + _arySltLine[2] + ',' + _arySltLine[3];
                    _MOVEOBJ.Points = _strLine1 + _moveLine + _strLine2;
                }
                document.getElementById(_MOVEOBJ.ID).outerHTML = _MOVEOBJ.toStringWithoutLabel();
                _FLOW.Modified = true;
            }
            break;
        case "proc_m": m = _clkPx.substr(0, _clkPx.length - 2) * 4 / 3;
            n = _clkPy.substr(0, _clkPy.length - 2) * 4 / 3;
            sqrta = Math.sqrt((x - m) * (x - m) + (y - n) * (y - n));
            if (_MOVEOBJ.tagName == 'DIV') {
                var newX = x - _CURRENTX;
                var newY = y - _CURRENTY;
                _MOVEOBJ.style.left = newX + 2;
                _MOVEOBJ.style.top = newY + 2;
            }
            else {
                if (sqrta > 10) {
                    var newX = x - _CURRENTX;
                    var newY = y - _CURRENTY;
                    if (newX < 0) {
                        newX = 0;
                    }
                    if (newY < 30) {
                        newY = 30;
                    }
                    _MOVEOBJ.style.left = getMinMod(newX, 10);
                    _MOVEOBJ.style.top = getMinMod(newY, 10);
                    if (_MOVEOBJ.tagName != 'DIV') {
                        changeProcPos(_MOVEOBJ);
                    }
                }
            }
            modifyPanelHeight(_MOVEOBJ, x, y, true);
            break;
        case "proc_n": var newH = y - parseInt(_MOVEOBJ.style.top);
            if (newH < 30) {
                if (_MOVEOBJ.tagName != 'DIV') {
                    newH = 30;
                }
                else {
                    newH = 20;
                }
            }
            _MOVEOBJ.style.height = getMinMod(newH, 10);
            if (_MOVEOBJ.tagName != 'DIV') {
                changeProcPos(_MOVEOBJ);
            }
            modifyPanelHeight(_MOVEOBJ, x, y, true);
            break;
        case "proc_e": var newW = x - parseInt(_MOVEOBJ.style.left);
            if (newW < 35) {
                newW = 35;
            }
            _MOVEOBJ.style.width = getMinMod(newW, 10);
            if (_MOVEOBJ.tagName != 'DIV') {
                changeProcPos(_MOVEOBJ);
            }
            modifyPanelHeight(_MOVEOBJ, x, y, true);
            break;
        case "proc_nw": var newW = x - parseInt(_MOVEOBJ.style.left);
            var newH = y - parseInt(_MOVEOBJ.style.top);
            if (newW < 30) {
                newW = 30;
            }
            if (newH < 30) {
                if (_MOVEOBJ.tagName != 'DIV') {
                    newH = 30;
                }
                else {
                    newH = 20;
                }
            }
            _MOVEOBJ.style.width = getMinMod(newW, 10);
            _MOVEOBJ.style.height = getMinMod(newH, 10);
            if (_MOVEOBJ.tagName != 'DIV') {
                changeProcPos(_MOVEOBJ);
            }
            modifyPanelHeight(_MOVEOBJ, x, y, true);
            break;
        case "rect": case "roundrect": case "diamond": case "oval": case "fillrect": var newX = x;
            var newY = y;
            var obj = document.all("_" + _MOVETYPE + "ui");
            if (newX < _CURRENTX) {
                obj.style.left = newX;
            }
            obj.style.width = Math.abs(newX - _CURRENTX);
            if (newY < _CURRENTY) {
                obj.style.top = newY;
            }
            obj.style.height = Math.abs(newY - _CURRENTY);
            modifyPanelHeight(obj, x, y, true);
            break;
        default: fireProcMouseMove(x, y);
            break;
    }
}
function doDocMouseUp() {
    if (event.button == 2) {
        return false;
    }
    var x = (event.x + document.body.scrollLeft) / _ZOOM;
    var y = (event.y + document.body.scrollTop) / _ZOOM;
    if (oOval) {
        document.body.removeChild(oOval);
    }
    oOval = null;
    switch (_MOVETYPE) {
        case "line_m": var ProcTo = "";
            ProcTo = _FLOW.getProcAtXY(x, y);
            if (ProcTo == null) {
                if (ptMoveType == "from" || ptMoveType == "to") {
                    _MOVEOBJ.Points = _strPt1 + _strSltPt + _strPt2;
                    document.getElementById(_MOVEOBJ.ID).outerHTML = _MOVEOBJ.toStringWithoutLabel();
                }
            }
            else {
                if (ptMoveType == "from" || ptMoveType == "to") {
                    var Proc1, Proc2;
                    Proc1 = _FLOW.getProcAtXY(_CURRENTX, _CURRENTY);
                    Proc2 = _FLOW.getProcAtXY(x, y);
                    var nearPt = getNearPt(ProcTo, x, y);
                    var strPt = nearPt.split("|~|")[0];
                    var arrPt = strPt.split(",");
                    var strPos = nearPt.split("|~|")[1];
                    var nX = arrPt[0].substr(0, arrPt[0].length - 2);
                    var nY = arrPt[1].substr(0, arrPt[1].length - 2);
                    var relX = strPos.split(",")[0];
                    var relY = strPos.split(",")[1];
                    if (ptMoveType == "from") {
                        Proc1 = ProcTo;
                        Proc2 = _FLOW.getProcByID(_MOVEOBJ.ToProc);
                    }
                    if (ptMoveType == "to") {
                        Proc1 = _FLOW.getProcByID(_MOVEOBJ.FromProc);
                        Proc2 = ProcTo;
                    }
                    var existProc = _FLOW.StepPathExists(Proc1.ID, Proc2.ID)
                    if ((Proc1.ID == Proc2.ID) || (existProc != null && existProc.ID != _MOVEOBJ.ID) || (Proc1.ProcType == "end" || Proc2.ProcType == "begin") || (_MOVEOBJ.FromProc == "begin" && ptMoveType == "from" && ProcTo.ID != _MOVEOBJ.FromProc) || (_MOVEOBJ.FromProc == "begin" && ptMoveType == "to" && ProcTo.ID != _MOVEOBJ.ToProc) || (_MOVEOBJ.FromProc != "begin" && ProcTo.ID == "begin")) {
                        if (existProc != null && existProc.ID != _MOVEOBJ.ID) {
                            alert("已经有一个路径从[" + _FLOW.getProcByID(Proc1.ID).Text + "]至[" + _FLOW.getProcByID(Proc2.ID).Text + "]，操作不成功");
                        }
                        if (Proc1.ProcType == "end" || Proc2.ProcType == "begin") {
                            alert("路径必须符合“起点不能是结束结点，终点不能是开始结点”的规则!");
                        }
                        if (Proc1.ID == Proc2.ID) {
                            alert("不能指向本身!");
                        }
                        _MOVEOBJ.Points = _strPt1 + _strSltPt + _strPt2;
                        document.getElementById(_MOVEOBJ.ID).outerHTML = _MOVEOBJ.toStringWithoutLabel();
                    }
                    else {
                        if (ptMoveType == "from") {
                            _MOVEOBJ.setPropValue("FromProc", ProcTo.ID);
                            _MOVEOBJ.fromRelX = relX;
                            _MOVEOBJ.fromRelY = relY;
                        }
                        if (ptMoveType == "to") {
                            _MOVEOBJ.setPropValue("ToProc", ProcTo.ID);
                            _MOVEOBJ.toRelX = relX;
                            _MOVEOBJ.toRelY = relY;
                        }
                        _MOVEOBJ.Points = _strPt1 + strPt + _strPt2;
                        document.getElementById(_MOVEOBJ.ID).outerHTML = _MOVEOBJ.toStringWithoutLabel();
                        _FLOW.Modified = true;
                    }
                }
            }
            var newobj = new TStep(_FLOW);
            newobj.clone(_MOVEOBJ)
            pushLog("editstep",
        {
            "_old": _MOVELINEOBJ, "_new": newobj
        }
        );
            if (oOval) {
                document.body.removeChild(oOval);
            }
            oOval = null;
            document.getElementById(_MOVEOBJ.ID).StrokeColor = document.getElementById(_MOVEOBJ.ID).fsc;
            _FOCUSTEDOBJ = document.getElementById(_MOVEOBJ.ID);
            document.getElementById(_MOVEOBJ.Label.ID).style.backgroundColor = '#dddddd';
            break;
        case "proc_m": case "proc_n": case "proc_e": case "proc_nw": if (_MOVEOBJ.tagName != 'DIV') {
                var Proc = _FLOW.getProcByID(_MOVEOBJ.id);
                var oldVal =
            {
                "X": Proc.X, "Y": Proc.Y, "Width": Proc.Width, "Height": Proc.Height
            };
                if (_MOVETYPE == "proc_m") {
                    Proc.setPropValue("X", _MOVEOBJ.style.left);
                    Proc.setPropValue("Y", _MOVEOBJ.style.top);
                }
                else {
                    Proc.setPropValue("Width", _MOVEOBJ.style.width);
                    Proc.setPropValue("Height", _MOVEOBJ.style.height);
                }
                if (Math.abs(parseInt(oldVal.X) - parseInt(Proc.X)) > 2 || Math.abs(parseInt(oldVal.Y) - parseInt(Proc.Y)) > 2 || Math.abs(parseInt(oldVal.Width) - parseInt(Proc.Width)) > 2 || Math.abs(parseInt(oldVal.Height) - parseInt(Proc.Height)) > 2) {
                    pushLog("moveproc",
                {
                    "objID": Proc.ID, "moveType": _MOVETYPE, "_old": oldVal, "_new":
                    {
                        "X": Proc.X, "Y": Proc.Y, "Width": Proc.Width, "Height": Proc.Height
                    }
                }
                );
                }
                stuffProp();
                _FLOW.Modified = true;
                saveStepsToProc(_MOVEOBJ);
            }
            else {
                var stepid = _MOVEOBJ.id.replace('lab', '');
                var Label = _FLOW.getStepByID(stepid).Label;
                if (_MOVETYPE == "proc_m") {
                    Label.X = _MOVEOBJ.style.left;
                    Label.Y = _MOVEOBJ.style.top;
                }
                else {
                    Label.Width = _MOVEOBJ.style.width;
                    Label.Height = _MOVEOBJ.style.height;
                }
            }
            if (oOval) {
                document.body.removeChild(oOval);
            }
            oOval = null;
            break;
        case "rect": case "roundrect": case "diamond": case "oval": case "fillrect": case "line": case "polyline": var obj = document.all("_" + (_MOVETYPE == "polyline" ? "line" : _MOVETYPE) + "ui");
            obj.style.display = "none";
            if (_MOVETYPE == "line" || _MOVETYPE == "polyline") {
                var Proc1, Proc2, Step;
                Proc1 = _FLOW.getProcAtXY(_CURRENTX, _CURRENTY);
                Proc2 = _FLOW.getProcAtXY(x, y);
                if (Proc1 == null || Proc2 == null) {
                    alert("起点或终点不是[任务]，请在[任务]图形上按住鼠标并拖动到某[任务]图形上松开.");
                    break;
                }
                if (_FLOW.StepPathExists(Proc1.ID, Proc2.ID) != null) {
                    alert("已经有一个路径从[" + _FLOW.getProcByID(Proc1.ID).Text + "]至[" + _FLOW.getProcByID(Proc2.ID).Text + "]，请更改!");
                    break;
                }
                if (Proc1.ID == Proc2.ID) {
                    alert("不能指向本身!");
                    break;
                }
                if (Proc1.ProcType == "begin") {
                    alert("开始节点不允许手动联线!");
                    break;
                }
                if (Proc1.ProcType == "end" || Proc2.ProcType == "begin") {
                    alert("路径必须符合“起点不能是结束结点，终点不能是开始结点”的规则!");
                    break;
                }
                Step = new TStep(_FLOW);
                Step.FromProc = Proc1.ID;
                Step.ToProc = Proc2.ID;
                Step.zIndex = 2;
                Step.ShapeType = "PolyLine";
                Step.Label.X = (_CURRENTX + x) / 2;
                Step.Label.Y = (_CURRENTY + y) / 2
                _FLOW.addStep(Step);
                pushLog("addstep", Step);
                DrawAll();
            }
            else {
                var Proc = new TProc(_FLOW, null, _MOVETYPE);
                Proc.X = parseInt(obj.style.left);
                Proc.Y = parseInt(obj.style.top);
                Proc.Width = parseInt(obj.style.width) + 'px';
                Proc.Height = parseInt(obj.style.height) + 'px';
                if (parseInt(obj.style.width) < 20 || parseInt(obj.style.height) < 20) {
                    switch (_MOVETYPE) {
                        case 'rect': Proc.Width = '35px';
                            Proc.Height = '100px';
                            break;
                        case 'diamond': Proc.Width = '100px';
                            Proc.Height = '60px';
                            break;
                        default: Proc.Width = '100px';
                            Proc.Height = '40px';
                            break;
                    }
                }
                _FLOW.addProc(Proc);
                pushLog("addproc", Proc);
                DrawAll();
            }
            break;
    }
    modifyPanelHeight(_MOVEOBJ, x, y, false)
    _MOVETYPE = "";
    _MOVELINEOBJ = null;
    _MOVEOBJ = null;
    return true;
}
function doDocSelectStart() {
    var oEvt = event.srcElement.tagName;
    if (oEvt != "INPUT") {
        return false;
    }
}
function doDocKeyDown() {
    switch (event.keyCode) {
        case 46: if (_FOCUSTEDOBJ != null && event.srcElement.tagName != "INPUT" && event.srcElement.tagName != "SELECT") {
                mnuDelObj();
            }
            break;
    }
}
function changeToSelectBtn() {
    var obj = document.getElementById('tbxToolbox_select');
    var objs = document.all("tbxToolbox_btn");
    for (var i = 0; i < objs.length; i++) {
        objs[i].className = "bon2";
    }
    obj.className = "bon1";
    _TOOLTYPE = obj.cType;
    document.all.Canvas.style.cursor = "default";
    return false;
}
function getFrameParent(obj) {
    var str = '';
    if (obj.frameElement && (obj.frameElement.name != '' || obj.frameElement.id != '')) {
        str = obj.frameElement.id != '' ? obj.frameElement.id : obj.frameElement.name;
        str = getFrameParent(obj.parent) + str + '.';
    }
    else {
        str = 'top.';
    }
    return str;
}
document.onselectstart = doDocSelectStart;
document.onmousedown = doDocMouseDown;
document.onmousemove = doDocMouseMove;
document.onmouseup = doDocMouseUp;
document.onkeydown = doDocKeyDown;
document.onerror = new Function("return false;");
var win = null;
function disWin(param) {
}
function setFieldPermissions(line) {
}
function modifyPanelHeight(obj, x, y, move) {
    if (obj && obj.tagName && _MOVETYPE != '') {
        var panel = document.getElementById('Canvas');
        pw = panel.offsetWidth;
        ph = panel.offsetHeight;
        var bottom = parseInt(obj.style.top) + parseInt(obj.style.height);
        var right = parseInt(obj.style.left) + parseInt(obj.style.width);
        if (move) {
            if ((ph - bottom) < 10) {
                panel.style.height = y + 40;
                document.body.scrollTop = document.body.scrollTop + 40;
            }
            if ((pw - right) < 10) {
                panel.style.width = x + 40;
                document.body.scrollLeft = document.body.scrollLeft + 40;
            }
        }
        else {
            if ((ph - bottom) > 60) {
                if (_FLOW.getBottomProc().ID == obj.id) {
                    panel.style.height = bottom + 10;
                }
            }
            if ((pw - right) > 60) {
                if (_FLOW.getRightProc().ID == obj.id) {
                    panel.style.width = right + 10;
                    document.body.scrollLeft = document.body.scrollLeft;
                }
            }
            if (document.body.offsetHeight > panel.style.height.replace('px', '')) {
                panel.style.height = document.body.offsetHeight;
            }
            if (document.body.offsetWidth > panel.style.width.replace('px', '')) {
                panel.style.width = document.body.offsetWidth;
            }
        }
        _FLOW.Width = panel.offsetWidth;
        _FLOW.Height = panel.offsetHeight;
    }
}
var mmenus = new Array();
var misShow = new Boolean();
misShow = false;
var misdown = new Boolean();
misdown = false;
var musestatus = false;
var mpopTimer = 0;
mmenucolor = 'Menu';
mfontcolor = 'MenuText';
mmenuoutcolor = '#CCCCFF';
mmenuincolor = '#CCCCFF';
mmenuoutbordercolor = '#000000';
mmenuinbordercolor = '#000000';
mmidoutcolor = '#AAAAAA';
mmidincolor = '#AAAAAA';
mmenuovercolor = 'MenuText';
mitemedge = '0';
msubedge = '1';
mmenuunitwidth = 74;
mmenuitemwidth = 160;
mmenuheight = 30;
mmenuwidth = '100%';
mmenuadjust = 0;
mmenuadjustV = -4;
mfonts = 'font-family: Verdana; font-size: 8pt; color: MenuText; ';
mcursor = 'default';
function mpopOut() {
    mpopTimer = setTimeout('mallhide()', 500);
}
function getReal(el, type, value) {
    temp = el;
    while ((temp != null) && (temp.tagName != "BODY")) {
        if (eval("temp." + type) == value) {
            El = temp;
            return el;
        }
        temp = temp.parentElement;
    }
    return el;
}
function mMenuRegister(menu) {
    mmenus[mmenus.length] = menu;
    return (mmenus.length - 1);
}
function mMenuItem(caption, command, target, isline, statustxt, img, sizex, sizey, pos) {
    this.caption = caption;
    this.command = command;
    this.target = target;
    this.isline = isline;
    this.statustxt = statustxt;
    this.img = img;
    this.sizex = sizex;
    this.sizey = sizey;
    this.pos = pos;
}
function mMenu(caption, command, target, img, sizex, sizey, pos) {
    this.items = new Array();
    this.caption = caption;
    this.command = command;
    this.target = target;
    this.img = img;
    this.sizex = sizex;
    this.sizey = sizey;
    this.pos = pos;
    this.id = mMenuRegister(this);
}
function mMenuAddItem(item) {
    this.items[this.items.length] = item
    item.parent = this.id;
    this.children = true;
}
mMenu.prototype.addItem = mMenuAddItem;
function mtoout(src) {
    src.style.border = 'solid 1';
    src.style.borderLeftColor = mmenuoutbordercolor;
    src.style.borderRightColor = mmenuinbordercolor;
    src.style.borderTopColor = mmenuoutbordercolor;
    src.style.borderBottomColor = mmenuinbordercolor;
    src.style.backgroundColor = mmenuoutcolor;
    src.style.color = mmenuovercolor;
}
function mtoin(src) {
    src.style.border = 'solid 1';
    src.style.borderLeftColor = mmenuinbordercolor;
    src.style.borderRightColor = mmenuoutbordercolor;
    src.style.borderTopColor = mmenuinbordercolor;
    src.style.borderBottomColor = mmenuoutbordercolor;
    src.style.backgroundColor = mmenuincolor;
    src.style.color = mmenuovercolor;
}
function mnochange(src) {
    src.style.borderLeftColor = mmenucolor;
    src.style.borderRightColor = mmenucolor;
    src.style.borderTopColor = mmenucolor;
    src.style.borderBottomColor = mmenucolor;
    src.style.backgroundColor = '';
    src.style.color = mfontcolor;
    src.style.border = 'solid 0';
}
function mallhide() {
    for (var nummenu = 0; nummenu < mmenus.length; nummenu++) {
        var themenu = document.all['mMenu' + nummenu];
        var themenudiv = document.all['mmenudiv' + nummenu];
        mnochange(themenu);
        mmenuhide(themenudiv);
    }
}
function mmenuhide(menuid) {
    menuid.style.visibility = 'hidden';
    misShow = false;
}
function mmenushow(menuid, pid) {
    menuid.style.left = mposflag.offsetLeft + pid.offsetLeft + mmenuadjust;
    menuid.style.top = mposflag.offsetTop + mmenutable.offsetHeight + mmenuadjustV;
    if (mmenuitemwidth + parseInt(menuid.style.left) > document.body.clientWidth + document.body.scrollLeft)
        menuid.style.left = document.body.clientWidth + document.body.scrollLeft - mmenuitemwidth;
    menuid.style.visibility = 'visible';
    misShow = true;
}
function mmenu_over(menuid, x) {
    toel = getReal(window.event.toElement, "className", "coolButton");
    fromel = getReal(window.event.fromElement, "className", "coolButton");
    if (toel == fromel) return;
    if (x == mmenus.length) {
        misShow = false;
        mallhide();
        mtoout(eval("mMenu" + x));
    }
    else {
        mallhide();
        mtoin(eval("mMenu" + x));
        mmenushow(menuid, eval("mMenu" + x));
    }
    clearTimeout(mpopTimer);
}
function mmenu_out(x) {
    toel = getReal(window.event.toElement, "className", "coolButton");
    fromel = getReal(window.event.fromElement, "className", "coolButton");
    if (toel == fromel) return;
    if (misShow) {
        mtoin(eval("mMenu" + x));
    }
    else {
        mnochange(eval("mMenu" + x));
    }
    mpopOut()
}
function mmenu_down(menuid, x) {
    if (misShow) {
        mmenuhide(menuid);
        mtoout(eval("mMenu" + x));
    }
    else {
        mtoin(eval("mMenu" + x));
        mmenushow(menuid, eval("mMenu" + x));
        misdown = true;
    }
}
function mmenu_up() {
    misdown = false;
}
function mmenuitem_over(x, i) {
    srcel = getReal(window.event.srcElement, "className", "coolButton");
    if (misdown) {
        mtoin(srcel);
    }
    else {
        mtoout(srcel);
    }
    mthestatus = mmenus[x].items[i].statustxt;
    if (mthestatus != "") {
        musestatus = true;
        window.status = mthestatus;
    }
    clearTimeout(mpopTimer);
}
function mmenuitem_out() {
    srcel = getReal(window.event.srcElement, "className", "coolButton");
    mnochange(srcel);
    if (musestatus) window.status = "";
    mpopOut()
}
function mmenuitem_down() {
    srcel = getReal(window.event.srcElement, "className", "coolButton");
    mtoin(srcel);
    misdown = true;
}
function mmenuitem_up() {
    srcel = getReal(window.event.srcElement, "className", "coolButton");
    mtoout(srcel);
    misdown = false;
}
function mexec2(x) {
    var cmd;
    if (mmenus[x].target == "blank") {
        cmd = "window.open('" + mmenus[x].command + "')";
    }
    else {
        cmd = mmenus[x].target + ".location=\"" + mmenus[x].command + "\"";
    }
    eval(cmd);
}
function mexec(x, i) {
    var cmd;
    mallhide();
    if (mmenus[x].items[i].target == "blank") {
        cmd = "window.open('" + mmenus[x].items[i].command + "')";
    }
    else {
        cmd = mmenus[x].items[i].target + ".location=\"" + mmenus[x].items[i].command + "\"";
    }
    eval(cmd);
}
function mbody_click() {
    if (misShow) {
        srcel = getReal(window.event.srcElement, "className", "coolButton");
        for (var x = 0; x <= mmenus.length; x++) {
            if (srcel.id == "mMenu" + x)
                return;
        }
        mallhide();
    }
}
function mwritetodocument() {
    var mwb = 1;
    var stringx = '<div id="mposflag" style="position:absolute;"></div><table id=mmenutable border=0 cellpadding=3 cellspacing=2 width=' + mmenuwidth + ' height=' + mmenuheight + ' bgcolor=' + mmenucolor + ' onselectstart="event.returnValue=false"' + ' style="cursor:' + mcursor + ';' + mfonts + ' border-left: ' + mwb + 'px solid ' + mmenuoutbordercolor + ';' + ' border-right: ' + mwb + 'px solid ' + mmenuinbordercolor + '; ' + 'border-top: ' + mwb + 'px solid ' + mmenuoutbordercolor + '; ' + 'border-bottom: ' + mwb + 'px solid ' + mmenuinbordercolor + '; padding:0px"><tr><td width="1"><img src="image/logo.gif" align="absmiddle" height="20" width="130" border="0"></td>'
    for (var x = 0; x < mmenus.length; x++) {
        var thismenu = mmenus[x];
        var imgsize = "";
        if (thismenu.sizex != "0" || thismenu.sizey != "0") imgsize = " width=" + thismenu.sizex + " height=" + thismenu.sizey;
        var ifspace = "";
        if (thismenu.caption != "") ifspace = "&nbsp;";
        stringx += "<td nowrap class=coolButton id=mMenu" + x + " style='border: " + mitemedge + "px solid " + mmenucolor + "' width=" + mmenuunitwidth + "px onmouseover=mmenu_over(mmenudiv" + x + "," + x + ") onmouseout=mmenu_out(" + x + ") onmousedown=mmenu_down(mmenudiv" + x + "," + x + ")";
        if (thismenu.command != "") {
            stringx += " onmouseup=mmenu_up();mexec2(" + x + ");";
        }
        else {
            stringx += " onmouseup=mmenu_up()";
        }
        if (thismenu.pos == "0") {
            stringx += " align=center><img align=absmiddle src='" + thismenu.img + "'" + imgsize + ">" + ifspace + thismenu.caption + "</td>";
        }
        else if (thismenu.pos == "1") {
            stringx += " align=center>" + thismenu.caption + ifspace + "<img align=absmiddle src='" + thismenu.img + "'" + imgsize + "></td>";
        }
        else if (thismenu.pos == "2") {
            stringx += " align=center background='" + thismenu.img + "'>&nbsp;" + thismenu.caption + "&nbsp;</td>";
        }
        else {
            stringx += " align=center>&nbsp;" + thismenu.caption + "&nbsp;</td>";
        }
        stringx += "";
    }
    stringx += "<td width=*>&nbsp;</td></tr></table>";
    for (var x = 0; x < mmenus.length; x++) {
        thismenu = mmenus[x];
        if (x == mmenus.length) {
            stringx += '<div id=mmenudiv' + x + ' style="visiable:none"></div>';
        }
        else {
            stringx += '<div id=mmenudiv' + x + ' style="cursor:' + mcursor + ';position:absolute;' + 'width:' + mmenuitemwidth + 'px; z-index:' + (x + 100);
            if (mmenuinbordercolor != mmenuoutbordercolor && msubedge == "0") {
                stringx += ';border-left: 1px solid ' + mmidoutcolor + ';border-top: 1px solid ' + mmidoutcolor;
            }
            stringx += ';border-right: 1px solid ' + mmenuinbordercolor + ';border-bottom: 1px solid ' + mmenuinbordercolor + ';visibility:hidden" onselectstart="event.returnValue=false">\n' + '<table background="image/xpbg.gif" width="100%" border="0" height="100%" align="center" cellpadding="0" cellspacing="2" ' + 'style="' + mfonts + ' border-left: 1px solid ' + mmenuoutbordercolor;
            if (mmenuinbordercolor != mmenuoutbordercolor && msubedge == "0") {
                stringx += ';border-right: 1px solid ' + mmidincolor + ';border-bottom: 1px solid ' + mmidincolor;
            }
            stringx += ';border-top: 1px solid ' + mmenuoutbordercolor + ';padding: 4px" bgcolor=' + mmenucolor + '>\n';
            for (var i = 0; i < thismenu.items.length; i++) {
                var thismenuitem = thismenu.items[i];
                var imgsize = "";
                if (thismenuitem.sizex != "0" || thismenuitem.sizey != "0") imgsize = " width=" + thismenuitem.sizex + " height=" + thismenuitem.sizey;
                var ifspace = "";
                if (thismenu.caption != "") ifspace = "&nbsp;";
                if (!thismenuitem.isline) {
                    stringx += "<tr><td class=coolButton style='border: " + mitemedge + "px solid " + mmenucolor + "' width=100% height=15px onmouseover=\"mmenuitem_over(" + x + "," + i + ");\" onmouseout=mmenuitem_out() onmousedown=mmenuitem_down() onmouseup=";
                    stringx += "mmenuitem_up();mexec(" + x + "," + i + "); ";
                    if (thismenuitem.pos == "0") {
                        stringx += "><img align=absmiddle src='" + thismenuitem.img + "'" + imgsize + ">" + ifspace + thismenuitem.caption + "</td></tr>";
                    }
                    else if (thismenuitem.pos == "1") {
                        stringx += ">" + thismenuitem.caption + ifspace + "<img align=absmiddle src='" + thismenuitem.img + "'" + imgsize + "></td></tr>";
                    }
                    else if (thismenuitem.pos == "2") {
                        stringx += "background='" + thismenuitem.img + "'>" + thismenuitem.caption + "</td></tr>";
                    }
                    else {
                        stringx += ">" + thismenuitem.caption + "</td></tr>";
                    }
                }
                else {
                    stringx += '<tr><td height="1" background="image/hr.gif" onmousemove="clearTimeout(mpopTimer);"><img height="1" width="1" src="none.gif" border="0"></td></tr>\n';
                }
            }
            stringx += '</table>\n</div>';
        }
    }
    document.write("<div align='left'>" + stringx + "</div>");
}
function ColorSelector() {
    this.toString = function () {
        var S = '<table cellspacing="0" cellpadding="0" border="1" bordercolor="black" ' + 'style="border-Collapse:collapse;position:absolute;display:none;z-index:60000;border-left:1 solid gray;border-top:1 solid gray" id="colortab" ' + 'onmouseover="cl_MouseOver(this);" onmouseup="cl_MouseUP(this);">';
        S += addtd();
        S += '<tr><td id=colorshow colspan=8 align=center></td><td id=colorshow colspan=9>#000000</td>' + '<td id=colorshow colspan=9 align=center bgcolor="navy" style="color:white;cursor:hand" onclick="hideColorSel();">取消</td></tr>' + '</table>';
        return S;
    }
}
function hideColorSel() {
    colortab.style.display = "none";
}
function showColorSel(ACtrl) {
    if (event.button == 2)
        return false;
    colortab.style.top = window.event.clientY + document.body.scrollTop;
    colortab.style.left = window.event.clientX + document.body.scrollLeft;
    var ttemp1 = eval(ACtrl).value;
    colorshow[0].bgColor = ttemp1;
    colorshow[1].style.color = ttemp1;
    colorshow[1].innerText = ttemp1
    colortab.theobjis = ACtrl;
    colortab.style.display = "block";
}
function cl_MouseOver(cl) {
    if (event.srcElement.id == '') {
        var ttemp1 = event.srcElement.bgColor;
        colorshow[0].bgColor = ttemp1;
        colorshow[1].style.color = ttemp1;
        colorshow[1].innerText = ttemp1
    }
}
function cl_MouseUP(cl) {
    if (event.srcElement.id == '') {
        if (event.button == 1) {
            eval(cl.theobjis).value = event.srcElement.bgColor;
            eval(cl.theobjis).style.backgroundColor = event.srcElement.bgColor;
        }
        hideColorSel();
    }
}
function addtd(theobjis) {
    var temptd1 = [], temptr1 = []
    for (r = 0; r < 10; r++) {
        for (i = 0; i < 25; i++) {
            var tmcor1 = Math.round(Math.random() * 255).toString(16) + Math.round(Math.random() * 255).toString(16) + Math.round(Math.random() * 255).toString(16);
            while (tmcor1.length < 6) {
                tmcor1 += Math.round(Math.random() * 9);
            }
            temptd1[i] = "<td style=width:6;height:6; bgcolor=" + tmcor1 + "></td>";
        }
        temptr1[r] = "<tr>" + temptd1.join("") + "</tr>"
        temptd1.slice(1, temptd1.length);
    }
    return temptr1.join("");
}
cl_Selector = new ColorSelector();
document.write(cl_Selector);
var _PopTimer = 0;
function contextMenu() {
    this.items = new Array();
    this.addItem = function (item) {
        this.items[this.items.length] = item;
    }
    this.show = function (oDoc) {
        var S = "";
        var i;
        S = "<div id=\"rightmenu\" style=\"BACKGROUND-COLOR: #ffffff; BORDER: #000000 1px solid; LEFT: 0px; POSITION: absolute; TOP: 0px; VISIBILITY: hidden; Z-INDEX: 10\">";
        S += "<table id=\"rightmenuTable\" class=\"menutable\" border=\"0\" height=\"";
        S += this.items.length * 25;
        S += "\" cellpadding=\"0\" cellspacing=\"0\">";
        S += "<tr height=\"3\"><td bgcolor=\"#d0d0ce\" width=\"2\"></td><td>";
        S += "<table class=\"menutable\" border=\"0\" width=\"100%\" height=\"100%\" cellpadding=0 cellspacing=0 bgcolor=\"#ffffff\">";
        S += "<tr><td bgcolor=\"#d0d0ce\" width=\"23\"></td><td><img src=\" \" height=\"1\" border=\"0\"></td></tr></table>";
        S += "</td><td width=\"2\"></td></tr>";
        S += "<tr><td bgcolor=\"#d0d0ce\"></td><td>";
        S += "<table id=\"rightmenuItem\" class=\"menutable\" border=\"0\" width=\"100%\" height=\"100%\" cellpadding=3 cellspacing=0 bgcolor=\"#ffffff\">";
        oDoc.write(S);
        for (i = 0; i < this.items.length; i++) {
            this.items[i].show(oDoc);
        }
        S = "</table></td><td></td></tr>";
        S += "<tr height=\"3\"><td bgcolor=\"#d0d0ce\"></td><td>";
        S += "<table class=\"menutable\" border=\"0\" width=\"100%\" height=\"100%\" cellpadding=0 cellspacing=0 bgcolor=\"#ffffff\">";
        S += "<tr><td bgcolor=\"#d0d0ce\" width=\"23\"></td><td><img src=\" \" height=\"1\" border=\"0\"></td></tr></table>";
        S += "</td><td></td></tr>";
        S += "</table></div>\n";
        oDoc.write(S);
    }
}
function contextItem(text, icon, cmd, type, tid) {
    this.text = text ? text : "";
    this.icon = icon ? icon : "";
    this.cmd = cmd ? cmd : "";
    this.type = type ? type : "menu";
    this.tid = tid ? tid : "";
    this.show = function (oDoc) {
        var S = "";
        if (this.type == "menu") {
            S += "<tr id=\"" + this.tid + "\" ";
            S += "onmouseover=\"changeStyle(this, 'on');\" ";
            S += "onmouseout=\"changeStyle(this, 'out');\" ";
            S += "onclick=\"hideMenu();";
            S += this.cmd;
            S += "\">";
            S += "<td class=\"ltdexit\" width=\"22\">";
            if (this.icon == "")
                S += "&nbsp;";
            else {
                S += "<img border=\"0\" src=\"";
                S += this.icon;
                S += "\" style=\"POSITION: relative\"></img>";
            }
            S += "</td><td class=\"mtdexit\">&nbsp;";
            S += this.text;
            S += "</td><td class=\"rtdexit\" width=\"5\">&nbsp;</td></tr>";
        }
        else if (this.type == "separator") {
            S += "<tr><td class=\"ltdexit\">&nbsp;</td>";
            S += "<td class=\"mtdexit\" colspan=\"2\"><hr color=\"#000000\" size=\"1\"></td></tr>";
        }
        oDoc.write(S);
    }
}
function changeStyle(obj, cmd) {
    if (obj) try {
        var imgObj = obj.children(0).children(0);
        if (cmd == 'on') {
            obj.children(0).className = "ltdfocus";
            obj.children(1).className = "mtdfocus";
            obj.children(2).className = "rtdfocus";
            if (imgObj) {
                if (imgObj.tagName.toUpperCase() == "IMG") {
                    imgObj.style.left = "-1px";
                    imgObj.style.top = "-1px";
                }
            }
        }
        else if (cmd == 'out') {
            obj.children(0).className = "ltdexit";
            obj.children(1).className = "mtdexit";
            obj.children(2).className = "rtdexit";
            if (imgObj) {
                if (imgObj.tagName.toUpperCase() == "IMG") {
                    imgObj.style.left = "0px";
                    imgObj.style.top = "0px";
                }
            }
        }
    }
    catch (e) {
    }
}
function StopTimeout() {
    clearTimeout(_PopTimer);
}
function StartTimeout() {
    if (_PopTimer == 0) _PopTimer = setTimeout('hideMenu()', 500);
}
function showMenu(str) {
    var x, y, w, h, ox, oy;
    x = event.clientX;
    y = event.clientY;
    var obj = document.getElementById("rightmenu");
    if (obj == null)
        return true;
    var items = document.getElementById("rightmenuItem").getElementsByTagName("TR");
    var itemTable = document.getElementById("rightmenuTable");
    var j = 0;
    for (var i = 0; i < items.length; i++) {
        items[i].style.display = "";
        if (str && str.indexOf(items[i].id) == -1) {
            items[i].style.display = "none";
        }
        else {
            j = j + 1;
        }
    }
    itemTable.style.height = j * 25 + "px";
    ox = document.body.clientWidth;
    oy = document.body.clientHeight;
    if (x > ox || y > oy) return false;
    w = obj.offsetWidth;
    h = obj.offsetHeight;
    if ((x + w) > ox) x = x - w;
    if ((y + h) > oy) y = y - h;
    obj.style.posLeft = x + document.body.scrollLeft;
    obj.style.posTop = y + document.body.scrollTop;
    obj.style.visibility = "visible";
    return false;
}
function hideMenu() {
    if (event.button == 0 && !_FOCUSTEDOBJ) {
        var obj = document.getElementById("rightmenu");
        if (obj == null) return true;
        obj.style.visibility = "hidden";
        obj.style.posLeft = 0;
        obj.style.posTop = 0;
    }
}
function writeContextStyle() {
    var S = "";
    S += "<STYLE type=text/css>";
    S += ".menutable {Font-FAMILY: \"Tahoma\",\"Verdana\",\"宋体\"; FONT-SIZE: 9pt}";
    S += ".mtdfocus {BACKGROUND-COLOR: #ccccff; BORDER-BOTTOM: #000000 1px solid; BORDER-TOP: #000000 1px solid; CURSOR: hand}";
    S += ".mtdexit {BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid}";
    S += ".ltdfocus {BACKGROUND-COLOR: #ccccff; BORDER-BOTTOM: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; CURSOR: hand}";
    S += ".ltdexit {BACKGROUND-COLOR: #d0d0ce; BORDER-BOTTOM: #d0d0ce 1px solid; BORDER-TOP: #d0d0ce 1px solid; BORDER-LEFT: #d0d0ce 1px solid}";
    S += ".rtdfocus {BACKGROUND-COLOR: #ccccff; BORDER-BOTTOM: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-RIGHT: #000000 1px solid; CURSOR: hand}";
    S += ".rtdexit {BACKGROUND-COLOR: #ffffff; BORDER-BOTTOM: #ffffff 1px solid; BORDER-TOP: #ffffff 1px solid; BORDER-RIGHT: #ffffff 1px solid}";
    S += "</STYLE>";
    document.write(S);
}
function toggleMenu(isEnable) {
    if (isEnable)
        document.oncontextmenu = showMenu;
    else
        document.oncontextmenu = new function () {
            return true;
        };
}
writeContextStyle();
function DrawContextMenu() {
}
DrawContextMenu();